Sign in to follow this  
asilviu

Relative position

Recommended Posts

asilviu    122
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 this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
what is azimuth and what is elevation here.

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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 this post


Link to post
Share on other sites
Bob Janova    769
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this