All orbiting objects start with an initial theta, phi, and radius values and also a 2D heading vector to specify the orbit.
Then every frame this information is updated in the following way:
direction = Vector2.Normalize(direction); theta += timeDelta * direction.X * orbitSpeed; phi -= timeDelta * direction.Y * orbitSpeed; pos.X = radius * (float)Math.Cos(theta) * (float)Math.Sin(phi); pos.Y = radius * (float)Math.Cos(phi); pos.Z = radius * (float)Math.Sin(theta) * (float)Math.Sin(phi); pos.Normalize(); pos = radius * pos;
Where direction is the heading direction, radius is the distance away from the centre, timeDelta is the time since the last frame, orbit speed is a speed constant for the orbit, theta is the angle about the y-axis, phi is the angle about the x-axis, and pos is the final position vector for the object.
This works fine when direction = (1, 0) or (0, 1), however when it is made to equal (1, 1) then the object does weird orbits and it seems to be due pos.z not being calculated correctly.
Below is an image of the problem:
bad orbit.jpg 221.57K
20 downloadsThe white repeating boxes show the motion of the bad orbit.
The expected orbit can be seen below:
expected orbit.jpg 146.2K
13 downloadsI will be very happy with any help I could get,
Thanks!

Find content
Not Telling