rotvec_c |
Table of contents
Procedurerotvec_c ( Transform a vector via a rotation ) void rotvec_c ( ConstSpiceDouble v1 [3], SpiceDouble angle, SpiceInt iaxis, SpiceDouble vout [3] ) AbstractTransform a vector to a new coordinate system rotated by `angle' radians about axis `iaxis'. This transformation rotates `v1' by -angle radians about the specified axis. Required_ReadingNone. KeywordsROTATION VECTOR Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1 I Vector whose coordinate system is to be rotated. angle I Angle of rotation in radians. iaxis I Axis of rotation (X=1, Y=2, Z=3). vout O Resulting vector expressed in the new coordinate system. Detailed_Inputv1 is a vector (typically representing a vector fixed in inertial space) which is to be expressed in another coordinate system. The vector remains fixed but the coordinate system changes. angle is an angle given in radians, through which the rotation is performed. iaxis is the index of the axis of rotation. The X, Y, and Z axes have indices 1, 2 and 3 respectively. Detailed_Outputvout is the vector expressed in the new coordinate system specified by the angle of rotation and axis. If m = [angle] iaxis represents the rotation matrix described by the `angle' and `iaxis', (refer to the routine rotate_c) then vout = m * v1 = [angle] * v1 iaxis ParametersNone. ExceptionsError free. 1) If the `iaxis' index is not in the range 1 to 3, it will be treated the same as that integer 1, 2, or 3 that is congruent to it mod 3. FilesNone. ParticularsA rotation about the first, i.e. X-axis, is described by .- -. | 1 0 0 | | 0 cos(theta) sin(theta) | | 0 -sin(theta) cos(theta) | `- -' A rotation about the second, i.e. Y-axis, is described by .- -. | cos(theta) 0 -sin(theta) | | 0 1 0 | | sin(theta) 1 cos(theta) | `- -' A rotation about the third, i.e. Z-axis, is described by .- -. | cos(theta) sin(theta) 0 | | -sin(theta) cos(theta) 0 | | 0 0 1 | `- -' rotvec_c decides which form is appropriate according to the value of `iaxis' and applies the rotation to the input vector. ExamplesThe numerical results shown for this example may differ across platforms. The results depend on the SPICE kernels used as input, the compiler and supporting libraries, and the machine specific arithmetic implementation. 1) Apply a rotation of -45.0 degrees about the +Z axis to a 3 dimensional vector. Example code begins here. /. Program rotvec_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables. ./ SpiceDouble angle; SpiceDouble vout [3]; SpiceInt iaxis; /. Input values. ./ SpiceDouble v1 [3] = { 1.414, 0.0, 0.0 }; angle = pi_c ( )/4; iaxis = 3; /. Rotate `v1' by `angle' radians about `iaxis'. ./ rotvec_c ( v1, angle, iaxis, vout ); printf( "Input vector : %9.3f %9.3f %9.3f\n", v1[0], v1[1], v1[2] ); printf( "Rotated vector: %9.3f %9.3f %9.3f\n", vout[0], vout[1], vout[2] ); return ( 0 ); } When this program was executed on a Mac/Intel/cc/64-bit platform, the output was: Input vector : 1.414 0.000 0.000 Rotated vector: 1.000 -1.000 0.000 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) E.D. Wright (JPL) Version-CSPICE Version 1.1.2, 04-AUG-2021 (JDR) Edited the header to comply with NAIF standard. Created complete code example from existing code fragments. -CSPICE Version 1.1.1, 04-OCT-1999 (NJB) Procedure line and abstract and were changed to dispel the impression that the input vector is rotated by +angle radians about the specified axis. -CSPICE Version 1.1.0, 22-OCT-1998 (NJB) Made input vector const. -CSPICE Version 1.0.0, 08-FEB-1998 (EDW) Index_Entriesrotate a vector |
Fri Dec 31 18:41:11 2021