casacore
 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(MVPosition) creates (x,y,z) from the given position
65 // <li> MVDirection(Double, Double, Double) creates with
66 // specified values and adjust to length of 1.
67 // <li> MVDirection(Double, Double) creates a MVDirection assuming that the two
68 // values are (in radians) angle along 'equator' and towards 'pole'.
69 // <li> MVDirection(Quantity, Quantity) creates a MVDirection assuming angles
70 // as in previous
71 // <li> <src>MVDirection(Quantum<Vector<Double> >)</src> creates an MVDirection
72 // from angle vector, assuming
73 // second as zero if not present, and pole if length 0. Assumes
74 // a direction cosine if 3 elements
75 // <li> <src>MVDirection(Vector<Double>)</src> creates an MVDirection with
76 // the same restrictions as previous one
77 // <li> <src>MVDirection(Vector<Quantum<Double> >)</src> creates an
78 // MVDirection with the same rstrictions as previous one; but
79 // with unit check.
80 // </ul>
81 // A void adjust() function normalises the vector to a length of 1;
82 // a get() returns as a
83 // Double 2-vector the angles of the direction cosines; a getAngle() returns
84 // a Quantum 2-vector, (uInt) returns the indicated element, and getValue
85 // returns the direction cosine vector.<br>
86 // Direction cosines can be added and subtracted: the result will be
87 // adjusted to a length of 1.<br>
88 // The multiplication of two direction cosines produces the inner product.<br>
89 // shift() methods are available to shift in angular coordinates. E.g.
90 // shift(Quantity(5, "arcsec"), Quantity(-7, "arcsec")) will shift 5 arcsec
91 // in longitude, and -7 arcsec in latitude. They have a trueAngle switch
92 // to shift in latitude and perpendicular (along a great circle) to it.
93 // </synopsis>
94 //
95 // <example>
96 // See <linkto class=MDirection>MDirection</linkto>
97 // </example>
98 //
99 // <motivation>
100 // To aid coordinate transformations
101 // </motivation>
102 //
103 // <todo asof="1998/04/22">
104 // <li> check if true shifts can be done faster
105 // </todo>
106 
107 class MVDirection : public MVPosition {
108 
109 public:
110 
111  //# Friends
112 
113  //# Constructors
114  // Default constructor generates a direction to the pole (i.e. (0,0,1))
115  MVDirection();
116  // Creates from an MVPosition
117  MVDirection(const MVPosition &other);
118  // Constructs with elevation = 0.
119  // <group>
120  MVDirection(Double in0);
121  MVDirection(const Quantity &angle0);
122  // </group>
123  // Creates a specified vector
124  MVDirection(Double in0, Double in1, Double in2);
125  // Creates the direction cosines from specified angles along equator (azimuth)
126  // and towards pole (,elevation).
127  MVDirection(Double angle0, Double angle1);
128  // Creates the direction cosines from specified angles
129  // <thrown>
130  // <li> AipsError if quantities not in angle format
131  // </thrown>
132  // <group>
133  MVDirection(const Quantity &angle0, const Quantity &angle1);
134  // If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1);
135  // direction cosines assumed (if 3).
136  // <thrown>
137  // <li> AipsError if more than 3 values or incorrect units
138  // </thrown>
139  MVDirection(const Quantum<Vector<Double> > &angle);
140  // </group>
141  // Create from Vector. Assumes angles if less than or equal than 2 elements.
142  // Assumes direction cosines if 3 elements.
143  // <thrown>
144  // <li> AipsError if more than 3 elements
145  // </thrown>
146  // <group>
147  MVDirection(const Vector<Double> &other);
148  MVDirection(const Vector<Quantity> &other);
149  // </group>
150 
151  //# Operators
152  // Addition and subtraction
153  // <group>
154  MVDirection &operator+=(const MVDirection &right);
155  MVDirection operator+(const MVDirection &right) const;
156  MVDirection &operator-=(const MVDirection &right);
157  MVDirection operator-(const MVDirection &right) const;
158  // </group>
159 
160  //# General Member Functions
161 
162  // Tell me your type
163  // <group>
164  static void assure(const MeasValue &in);
165  // </group>
166 
167  // Adjust the direction cosines to a length of 1
168  virtual void adjust();
169  // Adjust the direction cosines to a length of 1 and return the length value
170  virtual void adjust(Double &res);
171  // Re-adjust : taken from MVPosition.
172  //
173  // Clone data
174  virtual MeasValue *clone() const;
175  // Generate a 2-vector of angles (in rad)
176  Vector<Double> get() const;
177  // Get the latitude angle (rad)
178  Double getLat() const;
179  // and with specified units
180  Quantity getLat(const Unit &unit) const;
181  // Get the position angle between the directions. I.e. the angle between
182  // the direction from one to the pole, and from one to the other.
183  // <group>
184  Double positionAngle(const MVPosition &other) const;
185  Double positionAngle(const MVDirection &other) const;
186  Quantity positionAngle(const MVPosition &other,
187  const Unit &unit) const;
188  Quantity positionAngle(const MVDirection &other,
189  const Unit &unit) const;
190  // </group>
191  // Get the angular separation between two directions.
192  // <group>
193  Double separation(const MVPosition &other) const;
194  Double separation(const MVDirection &other) const;
195  Quantity separation(const MVPosition &other,
196  const Unit &unit) const;
197  Quantity separation(const MVDirection &other,
198  const Unit &unit) const;
199  // </group>
200  // Produce the cross product
201  MVDirection crossProduct(const MVDirection &other) const;
202  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
203  // records. The getXRecordValue() gets additional information for records.
204  // Note that the Vectors could be empty.
205  // <group>
206  virtual Vector<Quantum<Double> > getRecordValue() const;
207  virtual Vector<Quantum<Double> > getXRecordValue() const;
208  virtual Vector<Quantum<Double> > getTMRecordValue() const;
209  // </group>
210  // Set the internal value if correct values and dimensions
211  virtual Bool putValue(const Vector<Quantum<Double> > &in);
212  // Set the internal value, using the longitude and latitude (in rad) given
213  void setAngle(Double angle0, Double angle1);
214  // Shift the direction in longitude (radians if Double) and/or latitude.
215  // If the trueAngle switch is True, the longitude shift will be in
216  // angular units perpendicular to the direction to the pole at the shifted
217  // latitude, along a great circle.
218  // <group>
219  void shift(const Quantum<Double> &lng,
220  const Quantum<Double> &lat, Bool trueAngle=False);
221  void shift(Double lng, Double lat, Bool trueAngle=False);
222  void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
223  void shiftLongitude(Double lng, Bool trueAngle=False);
224  void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
225  void shiftLatitude(Double lat, Bool trueAngle=False);
226  void shift(const MVDirection &shft, Bool trueAngle=False);
227  // </group>
228  // Shift over an angle off in the direction pa. pa is measured from North,
229  // in the direction of increasing longitude.
230  // <group>
231  void shiftAngle(const Quantum<Double> &off,
232  const Quantum<Double> &pa);
233  void shiftAngle(Double off, Double pa);
234  // </group>
235 
236 protected:
237  //# Data
238 };
239 
240 //# Global functions
241 // Rotate a position vector
242 MVDirection operator*(const RotMatrix &left, const MVDirection&right);
243 MVDirection operator*(const MVDirection &left, const RotMatrix &right);
244 
245 
246 } //# NAMESPACE CASACORE - END
247 
248 #endif
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)
Tell me your type.
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
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.
MVPosition operator-() const
Addition and subtraction.
Vector of three direction cosines.
Definition: MVDirection.h:107
virtual Vector< Quantum< Double > > getXRecordValue() const
virtual Vector< Quantum< Double > > getTMRecordValue() const
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.