Original Post
Hi there! That´s my first post here in the math forums, so please be gentle ;) Okay, now right to the point, I´ll first post the problem and after that the solution I got right now and the problems I have. The problem: I have a path along some faces of a 3-dimensional object. This path is chopped into keyframes, consisting of position, normal (to face), tangent(to path) and bitangent (perpendicular to tangent and normal). That works fine so far. Now the real problem is: I need the three angles (let´s call them a,b and c) for a Euler rotation, rotating around Z-axis, then new X-axis and finally around the new Z-axis again (I think this is commonly referred to as ZX'Z''). The Euler rotation should line up the standard coordinate system (X, Y and Z axis) with the target coordinate system (bitangent, normal and tangent). I really need _the angles_, not a matrix that does the complete transformation for me or anything like that, just the angles. I´m emphasizing that to prevent misunderstandings. Okay, that´s the problem. Now to my solution so far: - I project the normal onto the XY plane. Let this projection be called nXY. Then I calculate the angle between nXY and the Y-axis ( c = asin(nXY.x)). According to some drawings I made I negate c in some cases. After rotating around the Z-axis by this angle, the X'-axis is perpendicular to the normal. This step seems to work all the time. - Let´s call the set of vectors that result from rotating the standard coordinate system XYZ around the Z-axis by c X'Y'Z'. Now I calculate the angle b between the normal and Z' (which still is pointing upwards): b = acos(normal.z), because normal.DotProduct(Z') = normal.z. After those two rotations the resulting vector Z'' should be parallel to the normal, yet in some cases it isn´t, which I don´t understand. - The last step would be to calculate the angle c between X'' and the bitangent as: c = acos(bitangent.DotProduct(X'')). After those three rotations X''' should be parallel to the bitangent, Y''' to the tangent and Z''' to the normal, yet there seems to be an error in step 2, which I just can´t figure out, so it would be really kind of you to help me out with that. Perhaps a link to an understandable kind of tutorial for that or something like that would help, or you can find the error out of your head. Any way, thx in advance!