3D coordinates transformation

Started by
9 comments, last by Buckeye 9 years, 6 months ago
Dear All

I have captured the camera's coordinates in a game SDK which is measured in meters relative to north/south/altitude.

I need to transform them nto coordinates relative to the sprite, regardless of its pitch, bank and heading.

I have tried the several 3D transfoms and rotations without success (I can't get the camera's fixed position if the sprite changes its pitch/bank for example)

http://planning.cs.uiuc.edu/node102.html

I even tried to transform sequentially, first the heading, then the bank and last the pitch.

How can I approach this problem?

I can post my formulas if helps.

Thanks!
Advertisement
Yes, perhaps you can post your formulas so we can see what you might be doing wrong.
You want the camera's world position transformed into the sprite's local space, right?

My wild guess is that you might just not be inverting your sprite's world matrix.

So:

Matrix = Build a matrix representing the sprite's orientation (and position!!)
Matrix = Invert the matrix.
Multiply your camera's position vector by the matrix.


If you're already doing all of that, then it's probably just a typo somewhere.

Thanks for your reply.

I have the following variables:

distanceN, distanceE, Altitude which are the camera distances in meters to the North, East and Vertical.

Then, the planes' Pitch, Bank and Heading are the values of these variables in radians.

Then I do it sequentially to see how each transfrom behaves.

EDIT: corrected signed in Formulas

For Heading transform:

tempx = distanceE * cos (Heading) - distanceN * sin(Heading);
tempz = distanceN * cos (Heading) + distanceE * sin(Heading);
tempy = Altitude;

tempx, tempy, tempz are the transformed coordinates for the transversal, vertical and longitudal axis respectively

Heading seems to work perfect.

then for Bank transform:

temp1x = tempy * sin(Bank) + tempx * cos(Bank);
temp1y = tempy * cos (Bank) - tempx * sin(Bank);
temp1z = tempz;

again temp1x, temp1y, temp1z are the transformed coordinates for the transversal, vertical and longitudal axis respectively

and finally for Pitch transform

z = -temp1y * sin(Pitch) + temp1z* cos(Pitch);
y = temp1y * cos(Pitch) + temp1z * sin(Pitch);
x = temp1x;

where x, y, z are the final transformed coordinates for the transversal, vertical and longitudal axis respectively.

Something is off with the Pitch and Bank piece.

Any hints?

Thanks !

The problem I am having is that when you combine Pitch and Bank rotations the above breakdown doesn't seem to work.

Any ideas?

Thanks

It appears that the order of your transformations may be the problem. Applying roll, pitch and yaw is commonly done in just that order, not yaw-roll-pitch as you have it.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

It appears that the order of your transformations may be the problem. Applying roll, pitch and yaw is commonly done in just that order, not yaw-roll-pitch as you have it.

Thanks Buckeye. Just a question, most probably I may have to apply the inverse of the roll, pitch and yaw - as I want to go back to the relative position to the sprite. Is my reading correct? If so, what order should I do?


Is my reading correct? If so, what order should I do?

I was still working on my first pot of coffee when I posted previously so I'd have to take a closer look. Since it's been almost an hour, I'm guessing you've already tried it. How did it work out?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


I was still working on my first pot of coffee when I posted previously so I'd have to take a closer look. Since it's been almost an hour, I'm guessing you've already tried it. How did it work out?

I doesn't work on this side. I am checking the signs in the above formula I posted. I will revert back as soon as I assure they have the right signs.

It appears that the order of your transformations may be the problem. Applying roll, pitch and yaw is commonly done in just that order, not yaw-roll-pitch as you have it.

Buckeye, your suggestion helped to figure out the order. The game does roll, pitch and draw as you mentioned. So to go back to the original coordinates, I applied the inverse of that - draw, pitch and woll. It works ! Thanks all for the help!

This topic is closed to new replies.

Advertisement