casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVDirection.h
Go to the documentation of this file.
1 //# MVDirection.h: Vector of three direction cosines
2 //# Copyright (C) 1996,1997,1998,1999,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_MVDIRECTION_H
29 #define CASA_MVDIRECTION_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward De
38 
39 // <summary> Vector of three direction cosines </summary>
40 
41 // <use visibility=export>
42 
43 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> <linkto class=MVPosition>MVPosition</linkto>
48 // <li> <linkto class=Vector>Vector</linkto>
49 // <li> <linkto class=Quantum>Quantum</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // From Measure, Value and Direction
54 // </etymology>
55 //
56 // <synopsis>
57 // An MVDirection is a 3-vector of direction cosines. It is based on the
58 // MVposition class. The main difference is that the length of the
59 // vector will be adjusted (normalised) to a length of 1 in all operations.
60 // It can be constructed with:
61 // <ul>
62 // <li> MVDirection() creates direction cosines for pole: (0,0,1)
63 // <li> MVDirection(MVDirection) creates a copy
64 // <li> MVDirection(Double, Double, Double) creates with
65 // specified values and adjust to length of 1.
66 // <li> MVDirection(Double, Double) creates a MVDirection assuming that the two
67 // values are (in radians) angle along 'equator' and towards 'pole'.
68 // <li> MVDirection(Quantity, Quantity) creates a MVDirection assuming angles
69 // as in previous
70 // <li> <src>MVDirection(Quantum<Vector<Double> >)</src> creates an MVDirection
71 // from angle vector, assuming
72 // second as zero if not present, and pole if length 0. Assumes
73 // a direction cosine if 3 elements
74 // <li> <src>MVDirection(Vector<Double>)</src> creates an MVDirection with
75 // the same restrictions as previous one
76 // <li> <src>MVDirection(Vector<Quantum<Double> >)</src> creates an
77 // MVDirection with the same rstrictions as previous one; but
78 // with unit check.
79 // </ul>
80 // A void adjust() function normalises the vector to a length of 1;
81 // a get() returns as a
82 // Double 2-vector the angles of the direction cosines; a getAngle() returns
83 // a Quantum 2-vector, (uInt) returns the indicated element, and getValue
84 // returns the direction cosine vector.<br>
85 // Direction cosines can be added and subtracted: the result will be
86 // adjusted to a length of 1.<br>
87 // The multiplication of two direction cosines produces the inner product.<br>
88 // shift() methods are available to shift in angular coordinates. E.g.
89 // shift(Quantity(5, "arcsec"), Quantity(-7, "arcsec")) will shift 5 arcsec
90 // in longitude, and -7 arcsec in latitude. They have a trueAngle switch
91 // to shift in latitude and perpendicular (along a great circle) to it.
92 // </synopsis>
93 //
94 // <example>
95 // See <linkto class=MDirection>MDirection</linkto>
96 // </example>
97 //
98 // <motivation>
99 // To aid coordinate transformations
100 // </motivation>
101 //
102 // <todo asof="1998/04/22">
103 // <li> check if true shifts can be done faster
104 // </todo>
105 
106 class MVDirection : public MVPosition {
107 
108 public:
109 
110  //# Friends
111 
112  //# Constructors
113  // Default constructor generates a direction to the pole (i.e. (0,0,1))
114  MVDirection();
115  // Copy constructor
116  MVDirection(const MVPosition &other);
117  // Constructs with elevation = 0.
118  // <group>
119  MVDirection(Double in0);
120  MVDirection(const Quantity &angle0);
121  // </group>
122  // Creates a specified vector
123  MVDirection(Double in0, Double in1, Double in2);
124  // Creates the direction cosines from specified angles along equator (azimuth)
125  // and towards pole (,elevation).
126  MVDirection(Double angle0, Double angle1);
127  // Creates the direction cosines from specified angles
128  // <thrown>
129  // <li> AipsError if quantities not in angle format
130  // </thrown>
131  // <group>
132  MVDirection(const Quantity &angle0, const Quantity &angle1);
133  // If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1);
134  // direction cosines assumed (if 3).
135  // <thrown>
136  // <li> AipsError if more than 3 values or incorrect units
137  // </thrown>
138  MVDirection(const Quantum<Vector<Double> > &angle);
139  // </group>
140  // Create from Vector. Assumes angles if less than or equal than 2 elements.
141  // Assumes direction cosines if 3 elements.
142  // <thrown>
143  // <li> AipsError if more than 3 elements
144  // </thrown>
145  // <group>
146  MVDirection(const Vector<Double> &other);
147  MVDirection(const Vector<Quantity> &other);
148  // </group>
149  // Copy assignment
150  MVDirection &operator=(const MVDirection &other);
151 
152  // Destructor
153  ~MVDirection();
154  //# Operators
155  // Addition and subtraction
156  // <group>
157  MVDirection &operator+=(const MVDirection &right);
158  MVDirection operator+(const MVDirection &right) const;
159  MVDirection &operator-=(const MVDirection &right);
160  MVDirection operator-(const MVDirection &right) const;
161  // </group>
162 
163  //# General Member Functions
164 
165  // Tell me your type
166  // <group>
167  virtual uInt type() const;
168  static void assure(const MeasValue &in);
169  // </group>
170 
171  // Adjust the direction cosines to a length of 1
172  virtual void adjust();
173  // Adjust the direction cosines to a length of 1 and return the length value
174  virtual void adjust(Double &res);
175  // Re-adjust : taken from MVPosition.
176  //
177  // Clone data
178  virtual MeasValue *clone() const;
179  // Generate a 2-vector of angles (in rad)
180  Vector<Double> get() const;
181  // Get the latitude angle (rad)
182  Double getLat() const;
183  // and with specified units
184  Quantity getLat(const Unit &unit) const;
185  // Get the position angle between the directions. I.e. the angle between
186  // the direction from one to the pole, and from one to the other.
187  // <group>
188  Double positionAngle(const MVPosition &other) const;
189  Double positionAngle(const MVDirection &other) const;
190  Quantity positionAngle(const MVPosition &other,
191  const Unit &unit) const;
192  Quantity positionAngle(const MVDirection &other,
193  const Unit &unit) const;
194  // </group>
195  // Get the angular separation between two directions.
196  // <group>
197  Double separation(const MVPosition &other) const;
198  Double separation(const MVDirection &other) const;
199  Quantity separation(const MVPosition &other,
200  const Unit &unit) const;
201  Quantity separation(const MVDirection &other,
202  const Unit &unit) const;
203  // </group>
204  // Produce the cross product
205  MVDirection crossProduct(const MVDirection &other) const;
206  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
207  // records. The getXRecordValue() gets additional information for records.
208  // Note that the Vectors could be empty.
209  // <group>
210  virtual Vector<Quantum<Double> > getRecordValue() const;
211  virtual Vector<Quantum<Double> > getXRecordValue() const;
212  virtual Vector<Quantum<Double> > getTMRecordValue() const;
213  // </group>
214  // Set the internal value if correct values and dimensions
215  virtual Bool putValue(const Vector<Quantum<Double> > &in);
216  // Set the internal value, using the longitude and latitude (in rad) given
217  void setAngle(Double angle0, Double angle1);
218  // Shift the direction in longitude (radians if Double) and/or latitude.
219  // If the trueAngle switch is True, the longitude shift will be in
220  // angular units perpendicular to the direction to the pole at the shifted
221  // latitude, along a great circle.
222  // <group>
223  void shift(const Quantum<Double> &lng,
224  const Quantum<Double> &lat, Bool trueAngle=False);
225  void shift(Double lng, Double lat, Bool trueAngle=False);
226  void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
227  void shiftLongitude(Double lng, Bool trueAngle=False);
228  void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
229  void shiftLatitude(Double lat, Bool trueAngle=False);
230  void shift(const MVDirection &shft, Bool trueAngle=False);
231  // </group>
232  // Shift over an angle off in the direction pa. pa is measured from North,
233  // in the direction of increasing longitude.
234  // <group>
235  void shiftAngle(const Quantum<Double> &off,
236  const Quantum<Double> &pa);
237  void shiftAngle(Double off, Double pa);
238  // </group>
239 
240 protected:
241  //# Data
242 };
243 
244 //# Global functions
245 // Rotate a position vector
246 MVDirection operator*(const RotMatrix &left, const MVDirection&right);
247 MVDirection operator*(const MVDirection &left, const RotMatrix &right);
248 
249 
250 } //# NAMESPACE CASACORE - END
251 
252 #endif
virtual uInt type() const
Tell me your type.
MVDirection crossProduct(const MVDirection &other) const
Produce the cross product.
Double separation(const MVPosition &other) const
Get the angular separation between two directions.
static void assure(const MeasValue &in)
virtual void adjust()
Adjust the direction cosines to a length of 1.
MVDirection()
Default constructor generates a direction to the pole (i.e.
MVDirection operator+(const MVDirection &right) const
virtual MeasValue * clone() const
Re-adjust : taken from MVPosition.
A 3x3 rotation matrix.
Definition: RotMatrix.h:85
MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right)
Rotate a EarthMagnetic vector with rotation matrix and other multiplications.
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
Double positionAngle(const MVPosition &other) const
Get the position angle between the directions.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
defines physical units
Definition: Unit.h:189
MVDirection & operator-=(const MVDirection &right)
Base class for values in a Measure.
Definition: MeasValue.h:107
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
Double getLat() const
Get the latitude angle (rad)
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A 3D vector in space.
Definition: MVPosition.h:113
void shiftLongitude(const Quantity &lng, Bool trueAngle=False)
void shift(const Quantum< Double > &lng, const Quantum< Double > &lat, Bool trueAngle=False)
Shift the direction in longitude (radians if Double) and/or latitude.
const Bool False
Definition: aipstype.h:44
void shiftLatitude(const Quantum< Double > &lat, Bool trueAngle=False)
void shiftAngle(const Quantum< Double > &off, const Quantum< Double > &pa)
Shift over an angle off in the direction pa.
void setAngle(Double angle0, Double angle1)
Set the internal value, using the longitude and latitude (in rad) given.
MVDirection & operator+=(const MVDirection &right)
Addition and subtraction.
~MVDirection()
Destructor.
MVPosition operator-() const
Addition and subtraction.
Vector of three direction cosines.
Definition: MVDirection.h:106
virtual Vector< Quantum< Double > > getXRecordValue() const
MVDirection & operator=(const MVDirection &other)
Copy assignment.
virtual Vector< Quantum< Double > > getTMRecordValue() const
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42