casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Euler.h
Go to the documentation of this file.
00001 //# Euler.h: Vector of Euler rotation angles
00002 //# Copyright (C) 1995,1996,1997,1998,1999
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: Euler.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_EULER_H
00029 #define CASA_EULER_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Quanta/Quantum.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward Declarations
00040 
00041 
00042 // <summary>
00043 // Vector of Euler rotation angles
00044 // </summary>
00045 
00046 // <use visibility=local>
00047 
00048 // <reviewed reviewer="tcornwel" date="1996/02/15" tests="tMeasMath" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //   <li> <linkto class=Vector>Vector</linkto> class
00053 //   <li> <linkto class=Quantum>Quantum</linkto> class for units
00054 //   <li> <linkto class=RotMatrix>RotMatrix</linkto> class for usage
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // Euler angles describe the rotation of a coordinate system
00059 // </etymology>
00060 //
00061 // <synopsis>
00062 // The Euler class is a vector of three angles, together with a vector of
00063 // three signed integers. The angles describe the rotation around an axis of a
00064 // coordinate system, the integers the actual axis around which to rotate.
00065 // The integer can be 0 (do not use this angle) or 1,2,3 to indicate the
00066 // axis.
00067 // Given angles (a1,a2,a3) and axes (i1,i2,i3), the actual rotation matrix
00068 // constructed will be:<br>
00069 // R = R<sub>i3</sub>(a3).R<sub>i2</sub>(a2).R<sub>i1</sub>(a1) <br>
00070 // It has the following constructors:
00071 // <ul>
00072 //   <li> Euler() creates a zero filled vector of length 3. Axes: (1,2,3)
00073 //   <li> Euler(Euler) creates a copy
00074 //   <li> Euler(Double, uInt, Double=0, uInt=0, Double=0, uInt=0) creates an 
00075 //              Euler with specified values
00076 //   <li> Euler(Double, Double=0, Double=0) creates an Euler with (1,2,3)
00077 //   <li> Euler(Quantity, uInt, Quantity=0, uInt=0, Quantity=0, uInt=0) creates
00078 //               an Euler with specified values
00079 //   <li> Euler(Quantity, Quantity=0, Quantity=0) creates an Euler with
00080 //              interpretation of angle units in the Quantities
00081 //   <li> Euler(<src>Quantum<Vector<Double> ></src>) creates a zero expanded
00082 //              Euler from at most the first three elements of Quantity
00083 //              vector; with (1,2,3) 
00084 //   <li> Euler(<src>Quantum<Vector<Double> >, Vector<uInt></src>) creates a 
00085 //              zero expanded Euler with given values
00086 // </ul>
00087 // It has a unary minus operator, which reverses the sign and order of the
00088 // three angles, and the order of the axes, to produce the Euler angles
00089 // for a rotation with opposite signs, so that <src>RotMatrix(-Euler)</src>
00090 // will generate the inverse rotation matrix as compared with
00091 // <src>RotMatrix(Euler)</src>.<br>
00092 // getAngle() functions return the Euler angles as a Quantum vector.<br>
00093 // Eulers have addition and subtraction (on the angles). Note that this
00094 // produces the correct angles for a combined rotation only if the
00095 // axes are identical.<br>
00096 // A (which) operator returns the indicated angle. Set/get functions
00097 // manipulate the axes.
00098 // </synopsis>
00099 //
00100 // <example>
00101 // <srcblock>
00102 //      Quantity angle(25,"deg");       // 25 degrees
00103 //      Euler eul(angle.get().getValue(),2); // rotate over axis 2 (radians)
00104 //      RotMatrix rot(eul);             // generates rotation matrix
00105 // </srcblock>  
00106 // </example>
00107 //
00108 // <motivation>
00109 // To use generated precession and nutation results
00110 // </motivation>
00111 //
00112 // <todo asof="1995/09/04">
00113 // </todo>
00114 
00115 class Euler
00116 {       
00117     public:
00118 //# Friends
00119 // Output Euler angles
00120     friend ostream &operator<<(ostream &os, const Euler &eul);
00121 
00122 //# Constructors
00123 // Default constructor generates zero filled Double vector of length 3, with
00124 // (1,2,3) axes
00125     Euler();
00126 // Copy constructor
00127     Euler(const Euler &other);
00128 // Copy assignment
00129     Euler &operator=(const Euler &other);
00130 // Constructs an Euler with specified angles and (1,2,3) axes
00131     Euler(Double in0, Double in1 = 0, Double in2 = 0);
00132 // Constructs an Euler with specified angles and axes
00133     Euler(Double in0, uInt ax0, Double in1 = 0, uInt ax1=0, Double in2 = 0,
00134           uInt ax2=0);
00135 // <thrown>
00136 //    <li> AipsError if non-angle units used
00137 // </thrown>
00138 // Constructs an Euler from specified angle quantities
00139 // <group>
00140     Euler(const Quantity &in0);
00141     Euler(const Quantity &in0, const Quantity &in1);
00142     Euler(const Quantity &in0, const Quantity &in1, 
00143           const Quantity &in2);
00144     Euler(const Quantity &in0, uInt ax0);
00145     Euler(const Quantity &in0, uInt ax0, const Quantity &in1, uInt ax1=0);
00146     Euler(const Quantity &in0, uInt ax0, const Quantity &in1, uInt ax1,
00147           const Quantity &in2, uInt ax2=0);
00148 // Constructs an Euler (zero filled) from elements of Quantity vector
00149 // <group>
00150     Euler(const Quantum<Vector<Double> > &in);
00151     Euler(const Quantum<Vector<Double> > &in, const Vector<uInt> &ax);
00152 // </group>
00153 // </group>
00154 
00155 // Destructor
00156     ~Euler();
00157 
00158 //# Operators
00159 // The unary minus reverses the sign and order of the Euler angles
00160     Euler operator-() const;
00161 // Addition and subtraction
00162 // <group>
00163     Euler &operator+=(const Euler &right);
00164     Euler operator+(const Euler &right) const;
00165     Euler &operator-=(const Euler &right);
00166     Euler operator-(const Euler &right) const;
00167 // </group>
00168 // Return the which' angle
00169 // <group>
00170     Double &operator()(uInt which);
00171     const Double &operator()(uInt which) const;
00172 // </group>
00173 
00174 //# General Member Functions
00175 // with the optional conversion units.
00176 // <group>
00177     Quantum<Vector<Double> > getAngle() const;
00178     Quantum<Vector<Double> > getAngle(const Unit &unit) const;
00179 // </group>
00180 
00181 // Set an axis
00182     void set(uInt which, uInt ax);
00183 
00184 // Set all axes
00185     void set(uInt ax0, uInt ax1, uInt ax2);
00186 
00187 // Get an axis
00188     Int get(uInt which) const;
00189 
00190 private:
00191 //# Data
00192 // Actual vector with 3 Euler angles
00193     Vector<Double> euler;
00194 // Axes
00195     Vector<Int> axes;
00196 
00197 //# Private Member Functions
00198 // The makeRad functions check and convert the input Quantities to radians
00199 // <group>
00200     static Double makeRad(const Quantity &in);
00201     static Vector<Double> makeRad(const Quantum<Vector<Double> > &in);
00202 // </group>
00203 };
00204 
00205 
00206 } //# NAMESPACE CASA - END
00207 
00208 #endif
00209 
00210