Mathterbation Complete!
Apr. 3rd, 2005 06:44 amYay!!!! Thanks for all the help guys! I was startign to think I was never going to get this thing working but looking at various examples and reading, I finally figured out that yes, I am an idiot. I did imperical testing in the wrong places and trusted documentation. Maya's help pages on MEL say it uses angle values for sin, cos, etc. I don't know why it says that. It does not. It uses radians.
ultraken had the formulas pretty-much spot-on. Here's what I finally ended up with in my program:
And now... A few choice (four-letter) words about Maya's MEL. It does not have a ROUND function, only FLOOR and CEIL. they also seem to choose to round down rather than doing something sensible. As demonstrated above, this is particularly annoying near 0 as is gives you '-0' which f***'s up your signs on your rotation matrix. It's also annoying because if the user set a number at 5, 10, 23, or any whole number, it will make it 4.99999999999999, 9.999999999999 22.999999999, etc. It also does not have any way to format your output so it will occassionaly write your data in scientific notation, making it unlikely to parse in some other programs. So a little further down int he code, I have a 'NoScience' routine which truncates and rounds numbers so that I get clean whole numbers and things like that. it also turned out that the 'matrix' Maya gives me is some hokey conglomoration of like 15 different things and it really isn't useful for anything I was doing.
Ohwell. On the bright side, I'd been meaning to brush up on matrix algebra and determinants for some electronics projects I wanted to do, so this was a good refresher course, and more importantly, IT WORKS!!!!
For all the people who gave me input and were patient with me being slow on the uptake, Thank you thank you thank you thank you thank you!!!!!!!!! *HUGS* I'm an obsessive compulsive and rather stubborn and I knew this was doable so I just could _NOT_ let it go. I've spent every waking hour banging my head against it.
string $roto=`xform -q -roo $pcNode`; //Get orientation.
//xyz zxy zyx
xform -p true -roo "xyz" $pcNode; //Force to orientation.
float $p[]=`xform -os -q -ro $pcNode`; //Get rotation.
xform -p true -roo $roto $pcNode; //Return to current orient.
float $x=deg_to_rad($p[0]); //Convert to radians.
float $y=deg_to_rad($p[1]);
float $z=deg_to_rad($p[2]);
if ($x <= 0 && $x > -0.0000000000001) $x=0.0;
if ($y <= 0 && $y > -0.0000000000001) $y=0.0;
if ($z <= 0 && $z > -0.0000000000001) $z=0.0;
float $A=cos($x);
float $B=sin($x);
float $C=cos($y);
float $D=sin($y);
float $E=cos($z);
float $F=sin($z);
$rx= rad_to_deg(asin($B * $C));
$ry= rad_to_deg(atan2($D, $A * $C));
$rz= rad_to_deg(atan2(-1 * $B * $D * $E + $A * $F, $B * $D * $F + $A * $E));
And now... A few choice (four-letter) words about Maya's MEL. It does not have a ROUND function, only FLOOR and CEIL. they also seem to choose to round down rather than doing something sensible. As demonstrated above, this is particularly annoying near 0 as is gives you '-0' which f***'s up your signs on your rotation matrix. It's also annoying because if the user set a number at 5, 10, 23, or any whole number, it will make it 4.99999999999999, 9.999999999999 22.999999999, etc. It also does not have any way to format your output so it will occassionaly write your data in scientific notation, making it unlikely to parse in some other programs. So a little further down int he code, I have a 'NoScience' routine which truncates and rounds numbers so that I get clean whole numbers and things like that. it also turned out that the 'matrix' Maya gives me is some hokey conglomoration of like 15 different things and it really isn't useful for anything I was doing.
Ohwell. On the bright side, I'd been meaning to brush up on matrix algebra and determinants for some electronics projects I wanted to do, so this was a good refresher course, and more importantly, IT WORKS!!!!
For all the people who gave me input and were patient with me being slow on the uptake, Thank you thank you thank you thank you thank you!!!!!!!!! *HUGS* I'm an obsessive compulsive and rather stubborn and I knew this was doable so I just could _NOT_ let it go. I've spent every waking hour banging my head against it.
(no subject)
Date: 2005-04-03 03:27 pm (UTC)(no subject)
Date: 2005-04-03 06:13 pm (UTC)The entire rest of my program is in hungarian notation. I've just tried so many things here that I was sick of typing in lfInitialX