📄 cwmtx.txt
字号:
CWTSpaceVector<T> operator -(const CWTSpaceVector<T> &) const; Space vector subtraction. CWTSpaceVector<T> operator -() const; Reverses the sign of every element in the space vector. CWTSpaceVector<T> operator *(T val) const; Space vector "scalar" multiplication svec*val CWTSpaceVector<T> operator %(const CWTSpaceVector<T> &) const; Space vector outer product. CWTSpaceVector<T> operator /(T val) const; Space vector "scalar" division. CWTSpaceVector<T> & operator =(const CWTSpaceVector<T> &); Space vector assignment. CWTSpaceVector<T> & operator +=(const CWTSpaceVector<T> &); Compound space vector addition and assignment. CWTSpaceVector<T> & operator -=(const CWTSpaceVector<T> &); Compound space vector subtraction and assignment. CWTSpaceVector<T> & operator *=(T val); Compound space vector "scalar" multiplication and assignment. CWTSpaceVector<T> & operator %=(const CWTSpaceVector<T> &); Compound space vector outer product and assignment. CWTSpaceVector<T> & operator /=(T val); Compound space vector "scalar" division and assignment.Related Global Functions and Operators CWTSpaceVector<T> operator *(T val, const CWTSpaceVector<T> &svec); Space vector "scalar" multiplication val*svec. CWTSpaceVector<T> operator *(const CWTSquareMatrix<T> &, const CWTSpaceVector<T> &); Space vector and square matrix multiplication smat*svec must yield a space vector.==============================================================================template <class T = double> CWTQuaternionHeader file "quatern.h"Description Class CWTQuaternion is a 4-dimensional vector which provides the quaternion operations used (not so often) in engineering and science problems (e.g. for body attitude determination. For more information on quaternions and their applications, see: "Spacecraft attitude determination and control", Edited by James Wertz, D. Reidel Publishing Company, Dordrecht: Holland, Boston: U.S.A., London: England. Or do a search on the internet for quaternions. There a lot of useful sites that explain quaternions better that I could.Base Classes public CWTVector<T>Public Constructors CWTQuaternion(); Default constructor. Constructs a vector with four elements in one column. CWTQuaternion(const CWTMatrix<T> &mat); Constructs a quaternion from a copy of a matrix. NOTE: The CWTMatrix should have one column with four elements. CWTQuaternion(const CWTVector<T> &vec); Constructs a quaternion from a copy of a vector. NOTE: The vector should have four elements. CWTQuaternion(const CWTQuaternion<T> &qtn); Copy constructor. CWTQuaternion(const CWTSpaceVector<T> &, T = 0); Constructs a quaternion from a space vector and an optional real value. The space vector will become the quaternion's imaginary part. The real value will become the quaternion's real part. CWTQuaternion(T, T, T, T); Constructs a quaternion directly from four real values. The elements' index runs from left to right, starting with 0. CWTQuaternion(const CWTMatrix<T> &mat, unsigned irowStart, unsignedicolStart); Contructs a quaternion in N_MAPPED status. The resulting quaternion is mapped into the argument matrix from element mat[irowStart][icolStart] to element mat[irowStart + 3][icolStart]. CWTQuaternion(const CWTVector<T>& vec, unsigned irowStart); Constructs a quaternion in N_MAPPED status. The resulting quaternion is mapped into the argument vector from element vec[irowStart] to element vec[irowStart + 3]. CWTQuaternion(const T &r, const CWTSpaceVector<T> &svec, const T &angle); Constructs a quaternion from its exponential form q = r * e^(n * theta) where n is a three-dimensional (space) unit vector and theta an angle in radians. r is equal to the absolute value of the quaternion.Pubblic Destructors------------------- ~CWTQuaternion(); Destroys a quaternion object.Public Member Functions void Dimension(); Dimensions a quaternion to have one column with four elements. NOTE: Since CWTQuaternion is derived from CWTVector and CWTVector in turn is derived from CWTMatrix, CWTMatrix<T>::Dimension(rows, cols) and CWTVector<T>::Dimension(rows) can be called for a CWTQuaternion as well, possibly creating a quaternion having more than four elements! This should be avoided since it can lead to run time errors. void MapInto(const CWTMatrix<T> &mat, unsigned irowStart, unsigned icolStart); Maps a quaternion into a matrix. The resulting mapping is identical to the corresponding mapping constructor void MapInto(const CWTVector<T> &vec, unsigned irowStart); Maps a quaternion into an ordinary vector. The resulting mapping is identical to the corresponding mapping constructor void StoreProduct(const CWTQuaternion<T> &, CWTQuaternion<T> &); Stores the product of the two argument quaternions in the destination quaternion. This function is provided for situations where using operator*() causes too much overhead because it has to construct a new result matrix each time it is called. void StoreConjugate(const CWTQuaternion<T> &); Stores the conjugate of the argument quaternion in the destination quaternion. This function is provided for situations where using conj(qtn) causes too much overhead because it has to construct a new result matrix each time it is called. void MakeConjugate(); Makes this quaternion its own conjugate. The original values in the destination quaternion are lost. CWTQuaternion<T> Unit() const; Returns a unit quaterion that has the same direction as the original quaterion but its norm is scaled up/down to 1.Operators CWTQuaternion<T> operator +(const CWTQuaternion<T> &) const; Quaternion addition. CWTQuaternion<T> operator -(const CWTQuaternion<T> &) const; Quaternion subtraction. CWTQuaternion<T> operator -() const; Reverses sign of quaternion, i.e. all elements. CWTQuaternion<T> operator *(T val) const; Quaternion "scalar" multiplication. quaternion*val. CWTQuaternion<T> operator *(const CWTQuaternion<T> &) const; Quaternion multiplication. CWTQuaternion<T> operator /(T val) const; Quaternion "scalar" division. CWTQuaternion<T> operator /(const CWTQuaternion<T> &qtn2) const; Quaternion division, performs qtn1*inv(qtn2). CWTQuaternion<T> & operator =(const CWTQuaternion<T> &); Quaternion assignment operator. (Not inherited.) CWTQuaternion<T> & operator =(const CWTSpaceVector<T> &); Assigns value of space vector to quaternion imaginary part, quaternion real part becomes zero. CWTQuaternion<T> & operator +=(const CWTQuaternion<T> &); Compound quaternion addition and assignment. CWTQuaternion<T> & operator -=(const CWTQuaternion<T> &); Compound quaternion subtraction and assignment. CWTQuaternion<T> & operator *=(T val); Compound quaternion "scalar" multiplication and assignment. CWTQuaternion<T> & operator *=(const CWTQuaternion<T> &); Compound quaternion multiplication and assignment. CWTQuaternion<T> & operator /=(T val); Compound quaternion "scalar" division and assignment. CWTQuaternion<T> & operator /=(const CWTQuaternion<T> &); Quaternion compound division.Related Global Functions and Operators-------------------------------------- CWTQuaternion<T> operator *(T value, CWTQuaternion<T> &qtn) Quaternion "scalar" multiplication val*quaternion. ELEM re(const CWTQuaternion<T> &qtn); Returns real part of a quaternion. CWTSpaceVector<T> im(const CWTQuaternion<T> &); Returns imaginary (vector) part of a quaternion. CWTQuaternion<T> conj(const CWTQuaternion<T> &qtn); Returns the conjugate of a quaternion. CWTQuaternion<T> inv(const CWTQuaternion<T> &qtn) Returns the inverse of a quaternion calculated as: conj(qtn)/norm(qtn).==============================================================================Header File "coordsys.h"Description Contains utility functions related to coordinate transformations.Global Functions CWTSquareMatrix<T> SmatFromEuler321(T sclrAbout3, T sclrAbout2, T sclrAbout1); Returns a transformation matrix which transforms coordinates from a reference axis system to coordinates in an axis system with Euler angles: sclrAbout3, sclrAbout2, sclrAbout1 relative to that reference axis system. NOTE: The rotations from the reference axis system to the new attitude will be carried out in the sequence: 3-2-1. I.e. first around the Z-axis, next around the Y-axis and finally around the X-axis. Hence the order of the arguments sclrAbout3, sclrAbout2, sclrAbout1 and the name of this function. Sometimes another rotation sequence is used e.g. 2-3-2. So always make sure you use the correct sequencing. CwMtx only supports the 3-2-1 sequence. NOTE: sclrAbout1 = rotation about X-axis (roll angle). sclrAbout2 = rotation about Y-axis (pitch angle). sclrAbout3 = rotation about Z-axis (yaw angle). T Euler321Angle1FromSmat(const CWTSquareMatrix<T> &smat); Calculates rotation angle about X-axis (roll angle) from transformation matrix. Calculated as: atan2(smat[1][2], smat[2][2]). Returns values in the interval [-pi, pi]. T Euler321Angle2FromSmat(const CWTSquareMatrix<T> &smat); Calculates rotation angle about Y-axis (pitch angle) from transformation matrix. Calculated as: asin(-smat[0][2]). Returns values in the interval [-pi/2, pi/2]. T Euler321Angle3FromSmat(const CWTSquareMatrix<T> &smat); Calculates rotation angle about Z-axis (yaw angle) from transformation matrix. Calculated as: atan2(smat[0][1], smat[0][0]). Returns values in the interval [-pi, pi]. T Euler321Angle1FromQtn(const CWTQuaternion<T> &qtn); Calculates rotation angle about X-axis (roll angle) from attitude quaternion. Calculated as: atan2(2*(qtn[1]*qtn[2] + qtn[0]*qtn[3]), -qtn[0]*qtn[0] - qtn[1]*qtn[1] + qtn[2]*qtn[2] + qtn[3]*qtn[3]) Returns values in the interval [-pi, pi]. T Euler321Angle2FromQtn(const CWTQuaternion<T> &qtn); Calculates rotation angle about Y-axis (pitch angle) from transformation matrix. Calculated as: asin(-2*(qtn[0]*qtn[2] - qtn[1]*qtn[3])). Returns values in the interval [-pi/2, pi/2]. T Euler321Angle3FromQtn(const CWTQuaternion<T> &qtn); Calculates rotation angle about Z-axis (yaw angle) from transformation matrix. Calculated as: atan2(2*(qtn[0]*qtn[1] + qtn[2]*qtn[3]), qtn[0]*qtn[0] - qtn[1]*qtn[1] - qtn[2]*qtn[2] + qtn[3]*qtn[3]). Returns values in the interval [-pi, pi]. CWTQuaternion<T> QtnFromEulerAxisAndAngle(const CWTSpaceVector<T> &svecAxis, T ang); Returns a quaternion representing a rigid body's attitude from its Euler axis and angle representation. CWTSpaceVector<T> EulerAxisFromQtn(const CWTQuaternion<T> &); Returns Euler axis from a quaternion representing a rigid body's attitude. T EulerAngleFromQtn(const CWTQuaternion<T> &); Returns Euler angle from a quaternion representing a rigid body's attitude. CWTQuaternion<T> QtnFromEuler321Angles(T sclrAbout3, T sclrAbout2, T sclrAbout1); Returns a quaternion representing a rigid body's attitude. The quaternion elements correspond to the Euler symmetric parameters of the body. The body's attitude must be entered in Euler angle representation with rotation order 3-2-1, i.e. first about Z-axis next about rotated Y-axis and finally about rotated X-axis (yaw - pitch - roll sequence). CWTSquareMatrix<T> SmatFromQtn(const CWTQuaternion<T> &); Returns the transformation matrix corresponding to a quaternion representing a rigid body's attitude. CWTQuaternion<T> QtnFromSmat(const CWTSquareMatrix<T> &); Returns the quaternion corresponding to a transformation matrix. CWTVector<T> AxisAngleFromQtn( const CWTQuaternion<T> &qtn ); Returns the euler axis corresponding to a quaternion. NOTE: This function duplicates EulerAxisFromQtn(qtn) it only has a different return type. CWTQuaternion<T> QtnFromAxisAngle( const CWTVector<T> &vAxis, const T sAngle ); Returns the quaternion corresponding to the a euler axis and angle pair. NOTE: This function duplicates QtnFromEulerAxisAndAngle(..) it only has a different function profile. CWTSquareMatrix<T> ChangeOfBasis(CWTSpaceVector< CWTSpaceVector<T> >&from, CWTSpaceVector< CWTSpaceVector<T> >&to) Returns the transformation matrix that transforms coordinated from the "from" axis system to the "to" axis system. The arguments of type CWTSpaceVector< CWTSpaceVector<T> > contain the unit vectors that represent the X, Y and Z-axis of the "from" and "to" axis systems respectively.Local Variables:mode: textfill-column: 78End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -