Determining direction of a moving, rotating object

I’m trying to do just a simple (i.e. really simplified) approximation of one object orbiting another abject that is itself orbitting another in 3D.

Using local position transformation, I’m able to have the engine calculate relative X and Z coordinates using a radius and frequency, then I’m using the Y axis from the parent object. (The parent object is just moving in a straight line right now so its y value is just increasing as the time elapses.)

So this gives me a perpendicular plane of orbit for my first child. Then in order to simulate a tilted orbit, I think I just need to calculate the amount of deflection from Y based on a limited radius equal to the angle of maximum tilt. This all works well so long as I assume the parent object is moving in a straight line along the one axis.

Where I’m having trouble is I want to have a third object orbiting the first child but because the direction of motion of the second object is no longer linear (keeps changing as it spirals around the first object), I can’t figure out how to calculate the Y value correctly.

If I could figure out an equation to figure out the direction of the perpendicular, relative Y of the second object, I would be able to then calculate the new Y position, including any wobble, for the third object. But my parent object only has its own current position (vector position) and can’t tell me about the plane or direction of its own movement.

Visualizing what is happening in my head if I were to draw a line following the pole I could see that line processing relative to the primary object, but I can’t figure out how I would calculate that simply.

Does anyone have logic or mathematical suggestions? Library suggestions?

you want to build a hierarchy, let’s name the bodies S (Sun), E (Earth), and M (Moon) for simplicity.
S is a parent of E, which is a parent of M. Assume all default transforms to begin with.

To offset a child object, move it in it’s parent’s space once on the X axis.
To introduce orbital rotation (revolution), rotate child (parent’s space) on the Y axis, each frame.
To introduce axial rotation, rotate child around its own center (local space) on the Y axis, each frame.
To introduce orbital inclination, parent the child to a imaginary object, then slightly rotate this object (parent’s space) on its X axis once.
To introduce axial tilt, parent the child to another imaginary object, then rotate this object however you want to reflect the tilt.

(edit: btw I’ve simplified the sentences a lot, that’s why I’m not referring to SME any more :slight_smile: )

I’m too lazy to draw a pretty picture, but try to do this step by step, and it’ll become easier to comprehend. Try to think of all operations independent of each other. For example, a planet rotates on its orbit around some barycenter The orbit has an angle of inclination against some common XZ plane These are clearly two independent entities with independent frames of rotation. If you compound them you will inevitably get weird motion.