planet orbit alg

Blitz3D Forums/Blitz3D Programming/planet orbit alg

verfum(Posted 2008) [#1]
Hi I'm trying to get a sphere to move around another sphere but I cant get the algorythm, I've tried sin and cos but it's not the same as 2D, any ideas?

Thanks.


KillerX(Posted 2008) [#2]
Create a pivot;
Position the pivot in the inner sphere;
Parent the outer sphere to the pivot; and
Rotate the pivot every frame.


verfum(Posted 2008) [#3]
Yeah I knew you could do that, but I really could do with the algorythm :)


GfK(Posted 2008) [#4]
Something like:
;Distance between planets
Dist# = 100

;position of planet 1
X1#=0
Y1#=0
Z1#=0

For A = 0 to 359
;position of planet 2
X2#=Cos(A) * Dist + X1
Z2#=Sin(A) * Dist + Z1
RenderWorld()
Flip
Next