# Relative position

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

##### Share on other sites
what is azimuth and what is elevation here.

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

##### Share on other sites
The vector between the two points / objects gives you all you need to derive the angles.

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×