RE: Euler rotation angles

*To*: mathgroup at smc.vnet.net*Subject*: [mg46752] RE: [mg46739] Euler rotation angles*From*: "David Park" <djmp at earthlink.net>*Date*: Fri, 5 Mar 2004 01:47:14 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

Sam, There is an Application at my web site called Rotations & EulerAngles that contains packages and routines that can do these calculations. Let's do an example. We can't obtain the Euler angles directly from two vectors but must first calculate a rotation matrix that transforms the first vector into the second. Here are two unit length vectors. vector1 = {1/Sqrt[2], 1/Sqrt[2], 0}; vector2 = {0, 0, -1}; axis = vector1\[Cross]vector2 {-(1/Sqrt[2]), 1/Sqrt[2], 0} The angle between the vectors is given by Cos[\[Theta]] == vector1.vector2 Cos[\[Theta]] == 0 The angle can be Pi/2 or -Pi/2 but the following routine uses the so called "alias" interpretation in entering angle. This cooresponds to rotating a frame about the axis so that vector2 is vector1 in the rotated frame. The angle is the negative of the angle for rotating vector1 to vector2. We rotate the frame by -Pi/2. We then use the following routine from the package. ?AxisRotationMatrix AxisRotationMatrix[axis, var:\[Theta]] will return a rotation matrix about the specified axis as a function of var. A positive angle will correspond to a right handed rotation of the frame about the axis. rotationmatrix = AxisRotationMatrix[axis, -\[Pi]/2] {{1/2, -(1/2), 1/Sqrt[2]}, {-(1/2), 1/2, 1/Sqrt[2]}, {-(1/Sqrt[2]), -(1/Sqrt[2]), 0}} We can check that this rotation matrix works. rotationmatrix.vector1 {0, 0, -1} We can see that this is a proper rotation matrix by checking that it is orthogonal and has determinant 1. {rotationmatrix.Transpose[rotationmatrix] == IdentityMatrix[3], Det[rotationmatrix]} {True, 1} Now we can calculate Euler angles. But there are 12 different sets of Euler angles depending on what rotation sequence you want to use. And each set has two solutions. We will use the following routine from the package. ?EulerAngles EulerAngles[matrix, seqstring, opts] will return the Euler angles corresponding to a sequence of axes rotations specified by seqstring. An axes sequence of "XYZ" means rotation around the X axes by \[Psi], followed by rotation about the Y axis by \[Theta], followed by rotation about the Z axis by \[Phi]. Two sets of rotations angles {\[Psi],\[Theta],\[Phi]} are returned. The first, canonical set, has -\[Pi]/2 <= \[Theta] <= \[Pi]/2 for ABC sequences and 0 <= \[Theta] <= \[Pi] for ABA sequences. The second solution corresponds to the other value of \[Theta] in the range -\[Pi] <= \[Theta] <= \[Pi]. The answers are in terms of the standard alibi matrices, unless alias is specified in the EAMode option. If the option EAMatrixTest is set to True, the routine will check if the matrix is a proper rotation matrix. If the matrix is degenerate for a given sequence, only \[Psi] ± \[Phi] can be determined. In this case, the \[Phi] = 0 solution is returned, with the corresponding second solution. The option EADegeneracyCriterion gives the criterion for determining degeneracy. Let's use the standard physics rotation sequence ZXZ. This means we rotate first about the Z axis by psi, then about the resulting X axis by thets and then again about the resulting Z axis by phi. EulerAngles[rotationmatrix, "ZXZ"] {{-((3*Pi)/4), Pi/2, (3*Pi)/4}, {Pi/4, -(Pi/2), -(Pi/4)}} So the first solution gives psi == -3 Pi/4, theta == Pi/2 and phi == 3 Pi/4 Second solution is psi == Pi/4, theta == -Pi/2 and phi == -Pi/4 In the package Rx[angle], Ry[angle] and Rz[angle] give the rotation matrices about the x, y and z axes. So we can check the above solution. Notice that the first rotation goes on the right. Rz[3*(Pi/4)] . Rx[Pi/2] . Rz[-3*(Pi/4)] . vector1 {0, 0, -1} Rz[-Pi/4] . Rx[-Pi/2] . Rz[Pi/4] . vector1 {0, 0, -1} Everything checks. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ Now that we have the rotation matrix From: S. Campbell [mailto:sam_campbell at hotmail.com] To: mathgroup at smc.vnet.net Hi, Can anyone help me with the following? I have two vectors, one rotated with respect to the other, and I wish to find the Euler rotation angles that connect the vectors. Can mathematica tell me what the required angles are? Cheers, Sam

**RE: Remote mathkernel through firewall behind NAT**

**NMinimize and WebServices**

**Re: Euler rotation angles**

**RE: Euler rotation angles**