View Full Version : Alternate Matrix

07 July 2007, 02:07 PM
We can set matrix attribute via setAttr alternate syntax: -type "matrix" "xform"

Is there a way to get matrix in this way? Everything seems to return it as double16. Well, actually we can just compose it quering stuff like scale/shear/rotatePivotTranslate and so on... But when it comes to jointOrient and rotateOrient - they need to be in quaternion and I don't know how to query or calculate these values.

Any ideas?

07 July 2007, 06:16 PM
mel doesn't support quats directly. Quats are just a vector plus a rotation. unit vector notation........
q = xi + yj + zk + w. So a quat can be represented by two coordinates. q =(w, v).
A vector Victor converted to quats is....q = (0, Victor)....just the vector orientation with zero rotation about it's axis.

Given an angle theta and an axis A you can convert to quats via...w = cos(theta / 2), v = sin(theta/2)*A A is normalized.

You can use angleBetween to get the rotation of a vector on to another and to rotate a point given an axis and angle:

vector $p = <<1, 0, 0>>;
vector $rotAxis = <<0, 0, 1>>;
float $rotAngle = deg_to_rad(90);
rot $p $rotAxis $rotAngle;

not a very pleasing answer. The api is much better for this stuff, transforms and matrix ops in particular. Plus with python, now you can use the api methods and wrappers in your scripts.

CGTalk Moderation
07 July 2007, 06:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.