Skip to main content
GameDev.net gamedev.net
🔒 Locked

Circular trajectories

Started by spanish May 24, 2002 at 5:19 PM 5 replies 350+ views
Original Post
spanish
spanish
I''ve studied centripedal physics, but I have very little idea of how to make a bitmap, or even a pixel, to travel in a circular path! I need to be able to do this based on a random radius from a constant pt., and a random starting (x,y) within a certain area (like the rings of saturn). Also, the pt. has a fixed mass, and so does the asteroid. If you can even just help me to make a pixel move in a circle it would help me immensely, thx. BTW: im using Visual C++, and Im sort of a newb, and don''t know much C. Thx again guys.
Pyabo
Pyabo
Um... Did you miss your Trigonometry class or what?

Here''s two big hints: sin(), cos()

You dig?
spanish
spanish
Sry, I''ve already sort of forgetten most of the trig. Pls, augment the hint (someone).
Peon
Peon
I dunno if this makes sense, but here's what I'm thinking:


    

while (true) //or whatever, just so that it loops

{
for (int i = 0; i < 2PI; i++)
{
xCoord = cos(i);
yCoord = sin(i);
}
}



Obviously, the values that this would return would not really be... correct for your game, but the ratios will be. You'll simply need to multiply them each by some number, so that it will display on the correct location on the screen. Also, that is more psuedo code that actual code, so just play around with it. Then again, you probably could figure that out yourself, hehe.

EDIT: I could be totally off, and I apologize in advance if I am... just some theoretical ramblings from a newbie who hasn't actually tried it yet

[edited by - Peon on May 25, 2002 3:03:26 AM]
Peon
Colin Jeanne
Colin Jeanne
x = r * cos(some_angle)
y = r * sin(some_angle)



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
Gee
Gee
Well, all of the posts gave you an idea how to create a circular motion... Of course by increasing the angle...

But you were talking about was the centripetal acceleration, which is a force perpendicular to the trajectory's normal... Just take the objects placement relative to the center (= r )... Then you normalize it, and multiply it with whatever centripetal acceleration you want (The vector is now not pointing towards the center, so multiply it by -1 first to give its antiparallel vector; -r /r )...

This gives you a = -(r /r ) * mag
where a is the acceleration vector and mag its magnitude...

Now just add a to your velocity vector and there you have it...

and of couse you need an inital velocity traveling only of inertia to create a nice symetrical circular motion.

Well, I might be incorrect in some of my expressions... but have in mind, English is my second language and I'm only 17... so read with care...

/G

[edited by - Gee on May 25, 2002 2:58:12 PM]
---GUI Programming Division Manager at Wildfire Gamesworking on the 0 A.D. project

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.