David Goering wrote:
Hey, thanks for the reply.
So it is better to use Matrix than MatrixTransform good to know.
Now if someone could give me an example or explain how the different rotation 
functions work that would be great, Ive searched arround, but somehow nothing 
seemed to work. (Id turn X,Y and Z into 0 ? )

what is the difference between makeRotate(), setRotate and rotate() ?
What is better to use?

No difference, really. rotate() will create a new matrix with the given rotation and return it, while makeRotate() and setRotate() just update the matrix that they're called on.


Maybe it would help to know my problem at a larger scale to give an answer, I 
need to transform one coordinate System into another, and to do that I have to 
rotate it by roughly 45° around the X-Axis (depending on webcam position to 
table) and then scale the axis by different scaling factors. At least that is 
the solution I have come up with.
So how do I best rotate a Transform Matrix by 45° arround the X-Axis and then 
apply a scaling to X,Y and Z values?

First, create the rotation matrix, then create the scaling matrix, then multiply them together:


rotate = osg::Matrix::rotate(osg::DegreesToRadians(45.0), 1.0, 0.0, 0.0);
scale = osg::Matrix::scale(xScale, yScale, zScale);

m = rotate * scale;


Note that the multiplication order of the matrices is significant, and I probably have it wrong (I usually do), so try it the other way if it doesn't work the first time. :-)


Another thing to keep in mind is that if you're transforming a *rotation* in one coordinate system to another coordinate system, you have to go an extra step. Essentially, you have to first transform to the original coordinate system, then apply the rotation, then transform back. So, if M is the transformation from the desired coordinate system to the original coordinate system and R is the rotation matrix in the original coordinate system, the proper transform to get the desired rotation, Rprime, is this:

Rprime = M * R * M.inverse();

Again, I might have the order wrong.

--"J"

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to