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

Circular based path movement..

Started by DevLiquidKnight Jan 29, 2004 at 12:46 AM 7 replies 750+ views
Original Post
DevLiquidKnight
DevLiquidKnight
I have a point type of directx light that im trying to make go around in a circle on the x,y axis planes in direct3d... so i can simulate a ''sun'' moving... but im not sure how to calculate the circular path based movement? anyone know how to calculate the next x and y coorindates?
Waverider
Waverider
You might want to make it time based and use sin() and cos() functions with a multiplication of radius to calculate the x,y values.

This of course assumes that in your 3D world, the z value is always zero.

To get the rotation to go around a variable axis, I think I''ll leave that to the math gurus.
It's not what you're taught, it's what you learn.
Waverider
Waverider
Sigh...

x = cos(time * K) * radius
y = sin(time * K) * radius

where K = some constant to give you the desired rate of movement in the circle.
It's not what you're taught, it's what you learn.
orbano
orbano
rotation on the x,y axis planes means you want the movement plane to be parallel to the x,y plane?

z=offsetz
x=offsetx+r*cos(phase);
y=offsety+r*sin(phase);

where r is the radius, offsetxyz are the centre. phase is the time-dependent component, increase its value in your loop (use small values);
if you want a movement not parallel to the x,y plane (enclosing alpha degrees with x and beta with y):
in the expression above, leave out the offset stuff (z=0, etx...)
after calculating the stuff above, you have to do this:
x=x*cos(alpha)+offsetx;
y=y*cos(beta)+offsety;
z=x*sin(alpha)+y*sin(beta)+offsetz;

im not sure if this is abslolutely ok (i mean the z value, x and y should be alright), but its early am here
btw you dont have to be a math guru for this. a programmer should have a basic understand of math. sin and cos is basic math. math gurus integrate functions and calculate matrix normals, etc...

"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin

[edited by - orbano on January 29, 2004 2:15:04 AM]
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
higherspeed
higherspeed
I''d argue that maths gurus aren''t interested in messing about with 3D vectors at all. It all sounds a bit applied to me
furby100
furby100
You will also get a circle if you apply an acceleration of constant magnitude equal to the square of the speed of the object divided by the radius of the circle perpendicular to the object's direction of motion.

[edited by - furby100 on January 30, 2004 10:21:37 AM]
psykr
psykr
But finding the path traveled by the circle through your method of applying acceleration with constant magnitude each frame could lead to floating point imprecision faster than the previous methods suggested (using sin/cos).
Besides, it doesn''t sound like the OP has much grounding in physics.
grhodes_at_work
grhodes_at_work
quote:
Original post by furby100
You will also get a circle if you apply an acceleration of constant magnitude equal to the square of the speed of the object divided by the radius of the circle perpendicular to the object''s direction of motion.

[edited by - furby100 on January 30, 2004 10:21:37 AM]


That''s sort of true. But, not quite, if the goal is a perfect circle. If you''re using numerical integration, such as Euler''s method or Runge-Kutta, Verlet, etc., then there actually will be numerical error that makes the path followed not quite a circle. Depending on whether the error is "dissipative" or "dispersive," the actual simulated path will either be a spiral (spiralling inward or outward) or just a not-quite circular closed path that may or may not be symmetric.

Still, physics based simulation can be a very nice way to control cameras and objects. Critical Mass Labs, for example, uses physic such as this to control cameras within SGI''s Performer real-time visualization system.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

Topic Locked

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

Sign in to reply to this topic.