Relative position

Started by
3 comments, last by Bob Janova 18 years, 1 month ago
Hi everyone, I have a problem determining the relative position of one object with respect to another. I have two records of the form: struct object { double x, y, z; //Coordinates of the object in space double azimuth, elevation, rotation //Orientation of the object in space } Let's say we have: object refPoint; //Reference point object a; I need the position and angles of the "a" object to be expressed relative to the "refPoint" object Can anyone help? Thanks a lot!
Advertisement
what is azimuth and what is elevation here.

For x,y,z and rotation you substract the second one with the first one.

The vector between the two points / objects gives you all you need to derive the angles.
Using your brain doesn't hurt at all.
azimuth is the angle between the object's X axis and the space X axis
elevation is the angle between the object's Y axis and the space Y axis
azimuth is the angle between the object's Z axis and the space Z axis

I am not sure what I should do with the vector between the two objects.
I need the angles and position of the second object to be expressed relative to the position and angles of the first object.
You need to do the inverse of the transformation required to project refPoint into the world to a, i.e. perform a world-space to object-space transformation.

The model-space to world-space matrix is a translation matrix times a rotation matrix. If you're using a 3D engine you ought to have this matrix calculated at some point. The transformation you need to apply to a is the inverse of this matrix. That will give you the location of a in refPoint's object space.

I'm not sure how to transform the angles, though =|. I would convert the directional information as a forward-vector and an up-vector, transform those (by the same matrix as above) and convert back to angles, but there is probably a better way.

This topic is closed to new replies.

Advertisement