How to convert a Camera if I only have an axis angle

Started by
12 comments, last by lucky6969b 12 years, 7 months ago
Hi,
I found this article.
http://www.toymaker.info/Games/html/camera.html
Just wondering if I just have an axis angle (an axis with a rotation angle)
and that I don't have enough info to convert it into 3 (yaw, pitch, roll) different matrices,
how do I go about solving up, right and look in this case?
Thanks
Jack
Advertisement
Whats the axis that you have represent? If its direction, then pick a temporary up like positive Y, cross product these two to get a side (or right) vector then cross the side with the original and get a new up.
It reads 0.709184 0.631360 0.313756 1.222444 It's from IGame (3dxi) The example game exporter.

Description: This class provides a representation for orientation in three space using an angle and axis. This class is similar to a quaternion, except that a normalized quaternion only represents -PI to +PI rotation. This class will have the number of revolutions stored. All methods of this class are implemented by the system.

The rotation convention in the 3ds Max API is the left-hand-rule. Note that this is different from the right-hand-rule used in the 3ds Max user interface. Data Members: Point3 axis;

The axis of rotation.

float angle;

The angle of rotation about the axis in radians. This angle is left handed.

You see there are 3 matrices to calculate ( I need 3 floats namely roll, pitch and yaw) , but I just had one value in an axis angle
Any example code?
Any clue? Thanks Jack
Any help would be greatly appreciated! Thanks
What 3dxi class/function are you working with that is returning this info? A better idea of what you are attempting to do might help.
Ok, well There is an example exporter coming with 3dxi. it exports to xml format I'd like to extract the Camera info, so that the Camera in d3d is positioned and oriented correctly Now that the exporter only shows me a axis angle value, And i came across that article at the meanwhile. Wondering just how to connect both concepts together. Thanks Jack
If you have an IGameNode representing the camera you can try pulling the transform info from it. Using IGameNode GetWorldTM() will return a GMatrix, you can then pull the cameras matrix rows or columns using GMatrix GetColumn() and GetRow().
You meant the GetWorldTM() method is returning the view matrix directly. No more computations are needed? Thanks
I am starting to catch this now. I think I need 3 bunches of axis vectors and 3 floats. But the exporter just gives one set which is really strange, I've looked at the output in depth and couldn't find the other ones. Thanks Jack

This is the ASCII dump of the Camera
[source]
*CAMERAOBJECT {
*NODE_NAME "Camera01"
*CAMERA_TYPE Target
*NODE_TM {
*NODE_NAME "Camera01"
*INHERIT_POS 0 0 0
*INHERIT_ROT 0 0 0
*INHERIT_SCL 1 1 1
*TM_ROW0 0.6726 0.7400 -0.0000
*TM_ROW1 -0.4469 0.4062 0.7971
*TM_ROW2 0.5898 -0.5361 0.6039
*TM_ROW3 546.8461 -133.5005 375.1562
*TM_POS 546.8461 -133.5005 375.1562
*TM_ROTAXIS -0.7092 -0.3138 -0.6314
*TM_ROTANGLE 1.2224
*TM_SCALE 1.0000 1.0000 1.0000
*TM_SCALEAXIS 0.0565 -0.0000 0.9984
*TM_SCALEAXISANG 0.3203
}
*NODE_TM {
*NODE_NAME "Camera01.Target"
*INHERIT_POS 0 0 0
*INHERIT_ROT 0 0 0
*INHERIT_SCL 0 0 0
*TM_ROW0 1.0000 0.0000 0.0000
*TM_ROW1 0.0000 1.0000 0.0000
*TM_ROW2 0.0000 0.0000 1.0000
*TM_ROW3 113.2334 260.6279 -68.8048
*TM_POS 113.2334 260.6279 -68.8048
*TM_ROTAXIS 0.0000 0.0000 0.0000
*TM_ROTANGLE 0.0000
*TM_SCALE 1.0000 1.0000 1.0000
*TM_SCALEAXIS 0.0000 0.0000 0.0000
*TM_SCALEAXISANG 0.0000
}
*CAMERA_SETTINGS {
*TIMEVALUE 0
*CAMERA_NEAR 0.0000
*CAMERA_FAR 1000.0000
*CAMERA_FOV 0.7854
*CAMERA_TDIST 735.1591
}
}
[/source]
The info you need seems to be there


// transform matrix
*TM_ROW0 0.6726 0.7400 -0.0000
*TM_ROW1 -0.4469 0.4062 0.7971
*TM_ROW2 0.5898 -0.5361 0.6039
*TM_ROW3 546.8461 -133.5005 375.1562 // translation

*TM_POS 546.8461 -133.5005 375.1562 // translation pulled from matrix

*TM_ROTAXIS -0.7092 -0.3138 -0.6314 // resulting axis from convert matrix to axis/angle
*TM_ROTANGLE 1.2224 // angle part of axis/angle conversion (in radians it seems)

*TM_SCALE 1.0000 1.0000 1.0000 // no scale (probably because its a camera)


you could take this info and convert it to angles if you want, look up matrix to yaw pitch roll.

This topic is closed to new replies.

Advertisement