Relative Motion

I’m trying to write a framechange scipt that will move an object “forward”. “Forward” defined as an increase along the X axis of the object. I’ve had limited success so far using non-matrix techniques.

So here is my question: Using the object matrix what would the method be for (as the frame number – or time-- changes) moving the object along the it’s X axis?

Basically what I’m going for it as the rotation of the object changes it’s direction of “forward” motion changes too.

Hopefully this makes sense to someone who knows the answer. Any help is greatly appreciated.

Thnx,
4MM

I don’t know if this is going to help you, but I’ll give it a try anyway…

If I understand correctly, you want to simulate the motion of an object.

You have some ‘law’ that defines the motion of the object in its local frame of reference, in your case you define the motion along the local x-axis of the object and rotations along the local axes.

The only thing you have to do is determine the relations between linear and angular velocity in the local frame of reference on the one hand and orientation and position derivatives in the global frame of reference on the other hand.

In aerospace engineering, the following equations define these relations:

thetadot    = q * cos(phi) - r * sin(phi);
psidot      = ( q * sin(phi) + r * cos(phi) ) / cos(theta);
phidot      = p + psidot * sin(theta);

% position (w. Euler angles)
xdot        = ( u * cos(theta) + ( v * sin(phi) + w * cos(phi) ) * sin(theta) )
    * cos(psi) - ( v * cos(phi) - w * sin(phi) ) * sin(psi);
ydot        = ( u * cos( theta ) + ( v * sin( phi ) + w * cos( phi ) ) * sin( theta ) ) * sin( psi ) + ( v * cos( phi ) - w * sin( phi ) ) * cos( psi );
zdot        = - u * sin( theta ) + ( v * sin( phi ) + w * cos( phi ) ) * cos( theta );

the following definitions apply:

u: linear velocity along the local X-axis of the object
v: linear velocity along the local Y-axis of the object
w: linear velocity along the local Z-axis of the object

p: angular velocity around the local X-axis of the object
q: angular velocity around the local Y-axis of the object
r: angular velocity around the local Z-axis of the object

theta, psi and phi are the usual Euler angles

If you define some laws that determine the motion in the local reference frame of the object for u,v,w,p,q and r as a function of time for example,
the only thing you have to do is integrate the above six equations using some time integration method (Euler, Heun or Runge Kutta) and then you can update setLocation() and setEuler() and advance a frame/second/time unit.

Example:
Lets say the laws that determine the motions of the object are the following:
u = 0.1t
v = 0.0
w = 0.0
p = 0.0
q = 0.0
r = 0.01
t
(these will result in some sort of horizontal turn)

then for a certain instant in time, calculate the values of u,v,w,p,q and r and substitute their values in the above equations of the derivatives.
Then integrate the six equations in time and update setLocation() and setEuler().

Euler time integration:

oldstates = states
f = dotcalc(states);
k1 = dt * f;
newstates   = oldstates + k1;

where
dotcalc: is a function that returns the results of the derivative equations
states: are the 12 states of your system,
newstates : are the integrated new states

Note that by using the euler angles, the motion of the object is not allowed to be vertical up , since then, the derivates of the euler angles are not defined. You can get around this by using quaternions to define the orientation of your object in space, but I dont have these relations here at the moment. (the above equations and relations came directly from a helicopter simulation program that I am working on for my thesis, and at the moment it works, so I think they are correct :slight_smile: )

Greetings,

Wim

Thank you sir! That’s more than enough information to have a go at it. And it addresses some additional areas I had not yet begun thinking about. Again, thanks.