Ellittic trjectory

Blitz3D Forums/Blitz3D Beginners Area/Ellittic trjectory

ingenium(Posted 2006) [#1]
How I could move a sphere around a cube following an ellittic trajectory?
Edit: sorry for the error in the topic: Ellittic Trajectory
Edit2: Douch! I wanted to write Elliptic Trajectory... I must write more slowly...


Ross C(Posted 2006) [#2]
This should do the trick. It uses Cos and Sin functions to move the sphere on an eliptical orbit. Adjust the X and Y raduis's to alter the orbit.

Graphics3D 800,600
SetBuffer BackBuffer()

Global cam = CreateCamera()
PositionEntity cam,0,20,0
RotateEntity cam,90,0,0


Global cube = CreateCube()

Global s = CreateSphere()

Global orbit_raduis_x# = 10
Global orbit_raduis_y# = 5
Global angle# = 0
Global orbit_Speed# = 1

While Not KeyHit(1)


	update_orbit()

	UpdateWorld
	RenderWorld
	Flip
Wend
End

Function update_orbit()

	angle = angle + orbit_speed
	PositionEntity s,EntityX(cube) + Cos(angle)*orbit_raduis_x,0,EntityZ(cube) + Sin(angle)*orbit_raduis_y
	
End Function


The part that alters the orbit is this part:

angle = angle + orbit_speed
	PositionEntity s,EntityX(cube) + Cos(angle)*orbit_raduis_x,0,EntityZ(cube) + Sin(angle)*orbit_raduis_y


The part that determines the orbit is this part. It takes the position of the cube, adds the Sin of the angle, multiplied by the orbit raduis, and the cos to the X and Z, and produces the circular movement.


ingenium(Posted 2006) [#3]
Thnx Very (and I mean VERY) much!


Ross C(Posted 2006) [#4]
No worries man :o)