casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_MVDIRECTION_H
27#define CASA_MVDIRECTION_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Quanta/MVPosition.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward De
36
37// <summary> Vector of three direction cosines </summary>
38
39// <use visibility=export>
40
41// <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
42// </reviewed>
43
44// <prerequisite>
45// <li> <linkto class=MVPosition>MVPosition</linkto>
46// <li> <linkto class=Vector>Vector</linkto>
47// <li> <linkto class=Quantum>Quantum</linkto>
48// </prerequisite>
49//
50// <etymology>
51// From Measure, Value and Direction
52// </etymology>
53//
54// <synopsis>
55// An MVDirection is a 3-vector of direction cosines. It is based on the
56// MVposition class. The main difference is that the length of the
57// vector will be adjusted (normalised) to a length of 1 in all operations.
58// It can be constructed with:
59// <ul>
60// <li> MVDirection() creates direction cosines for pole: (0,0,1)
61// <li> MVDirection(MVDirection) creates a copy
62// <li> MVDirection(MVPosition) creates (x,y,z) from the given position
63// <li> MVDirection(Double, Double, Double) creates with
64// specified values and adjust to length of 1.
65// <li> MVDirection(Double, Double) creates a MVDirection assuming that the two
66// values are (in radians) angle along 'equator' and towards 'pole'.
67// <li> MVDirection(Quantity, Quantity) creates a MVDirection assuming angles
68// as in previous
69// <li> <src>MVDirection(Quantum<Vector<Double> >)</src> creates an MVDirection
70// from angle vector, assuming
71// second as zero if not present, and pole if length 0. Assumes
72// a direction cosine if 3 elements
73// <li> <src>MVDirection(Vector<Double>)</src> creates an MVDirection with
74// the same restrictions as previous one
75// <li> <src>MVDirection(Vector<Quantum<Double> >)</src> creates an
76// MVDirection with the same rstrictions as previous one; but
77// with unit check.
78// </ul>
79// A void adjust() function normalises the vector to a length of 1;
80// a get() returns as a
81// Double 2-vector the angles of the direction cosines; a getAngle() returns
82// a Quantum 2-vector, (uInt) returns the indicated element, and getValue
83// returns the direction cosine vector.<br>
84// Direction cosines can be added and subtracted: the result will be
85// adjusted to a length of 1.<br>
86// The multiplication of two direction cosines produces the inner product.<br>
87// shift() methods are available to shift in angular coordinates. E.g.
88// shift(Quantity(5, "arcsec"), Quantity(-7, "arcsec")) will shift 5 arcsec
89// in longitude, and -7 arcsec in latitude. They have a trueAngle switch
90// to shift in latitude and perpendicular (along a great circle) to it.
91// </synopsis>
92//
93// <example>
94// See <linkto class=MDirection>MDirection</linkto>
95// </example>
96//
97// <motivation>
98// To aid coordinate transformations
99// </motivation>
100//
101// <todo asof="1998/04/22">
102// <li> check if true shifts can be done faster
103// </todo>
104
105class MVDirection : public MVPosition {
106 public:
107 // # Friends
108
109 // # Constructors
110 // Default constructor generates a direction to the pole (i.e. (0,0,1))
112 // Creates from an MVPosition
113 MVDirection(const MVPosition &other);
114 // Constructs with elevation = 0.
115 // <group>
117 MVDirection(const Quantity &angle0);
118 // </group>
119 // Creates a specified vector
121 // Creates the direction cosines from specified angles along equator (azimuth)
122 // and towards pole (,elevation).
123 MVDirection(Double angle0, Double angle1);
124 // Creates the direction cosines from specified angles
125 // <thrown>
126 // <li> AipsError if quantities not in angle format
127 // </thrown>
128 // <group>
129 MVDirection(const Quantity &angle0, const Quantity &angle1);
130 // If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1);
131 // direction cosines assumed (if 3).
132 // <thrown>
133 // <li> AipsError if more than 3 values or incorrect units
134 // </thrown>
136 // </group>
137 // Create from Vector. Assumes angles if less than or equal than 2 elements.
138 // Assumes direction cosines if 3 elements.
139 // <thrown>
140 // <li> AipsError if more than 3 elements
141 // </thrown>
142 // <group>
145 // </group>
146
147 // # Operators
148 // Addition and subtraction
149 // <group>
151 MVDirection operator+(const MVDirection &right) const;
153 MVDirection operator-(const MVDirection &right) const;
154 // </group>
155
156 // # General Member Functions
157
158 // Tell me your type
159 // <group>
160 static void assure(const MeasValue &in);
161 // </group>
162
163 // Adjust the direction cosines to a length of 1
164 virtual void adjust();
165 // Adjust the direction cosines to a length of 1 and return the length value
166 virtual void adjust(Double &res);
167 // Re-adjust : taken from MVPosition.
168 //
169 // Clone data
170 virtual MeasValue *clone() const;
171 // Generate a 2-vector of angles (in rad)
173 // Get the latitude angle (rad)
174 Double getLat() const;
175 // and with specified units
176 Quantity getLat(const Unit &unit) const;
177 // Get the position angle between the directions. I.e. the angle between
178 // the direction from one to the pole, and from one to the other.
179 // <group>
180 Double positionAngle(const MVPosition &other) const;
181 Double positionAngle(const MVDirection &other) const;
182 Quantity positionAngle(const MVPosition &other, const Unit &unit) const;
183 Quantity positionAngle(const MVDirection &other, const Unit &unit) const;
184 // </group>
185 // Get the angular separation between two directions.
186 // <group>
187 Double separation(const MVPosition &other) const;
188 Double separation(const MVDirection &other) const;
189 Quantity separation(const MVPosition &other, const Unit &unit) const;
190 Quantity separation(const MVDirection &other, const Unit &unit) const;
191 // </group>
192 // Produce the cross product
194 // Get the internal value as a <src>Vector<Quantity></src>. Usable in
195 // records. The getXRecordValue() gets additional information for records.
196 // Note that the Vectors could be empty.
197 // <group>
201 // </group>
202 // Set the internal value if correct values and dimensions
203 virtual Bool putValue(const Vector<Quantum<Double>> &in);
204 // Set the internal value, using the longitude and latitude (in rad) given
205 void setAngle(Double angle0, Double angle1);
206 // Shift the direction in longitude (radians if Double) and/or latitude.
207 // If the trueAngle switch is True, the longitude shift will be in
208 // angular units perpendicular to the direction to the pole at the shifted
209 // latitude, along a great circle.
210 // <group>
211 void shift(const Quantum<Double> &lng, const Quantum<Double> &lat, Bool trueAngle = False);
212 void shift(Double lng, Double lat, Bool trueAngle = False);
213 void shiftLongitude(const Quantity &lng, Bool trueAngle = False);
214 void shiftLongitude(Double lng, Bool trueAngle = False);
215 void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle = False);
216 void shiftLatitude(Double lat, Bool trueAngle = False);
217 void shift(const MVDirection &shft, Bool trueAngle = False);
218 // </group>
219 // Shift over an angle off in the direction pa. pa is measured from North,
220 // in the direction of increasing longitude.
221 // <group>
224 // </group>
225
226 protected:
227 // # Data
228};
229
230// # Global functions
231// Rotate a position vector
232MVDirection operator*(const RotMatrix &left, const MVDirection &right);
233MVDirection operator*(const MVDirection &left, const RotMatrix &right);
234
235} // namespace casacore
236
237#endif
MVDirection(Double angle0, Double angle1)
Creates the direction cosines from specified angles along equator (azimuth) and towards pole (,...
void shift(Double lng, Double lat, Bool trueAngle=False)
MVDirection(Double in0)
Constructs with elevation = 0.
MVDirection(const Vector< Double > &other)
Create from Vector.
void shiftLatitude(Double lat, Bool trueAngle=False)
MVDirection(const Vector< Quantity > &other)
virtual MeasValue * clone() const
Re-adjust : taken from MVPosition.
static void assure(const MeasValue &in)
Tell me your type.
void shiftLatitude(const Quantum< Double > &lat, Bool trueAngle=False)
MVDirection & operator-=(const MVDirection &right)
void shiftAngle(Double off, Double pa)
MVDirection(Double in0, Double in1, Double in2)
Creates a specified vector.
virtual void adjust()
Adjust the direction cosines to a length of 1.
MVDirection(const MVPosition &other)
Creates from an MVPosition.
Quantity separation(const MVDirection &other, const Unit &unit) const
MVDirection(const Quantum< Vector< Double > > &angle)
If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1); direction cosines as...
virtual Vector< Quantum< Double > > getTMRecordValue() const
Quantity positionAngle(const MVPosition &other, const Unit &unit) const
Quantity positionAngle(const MVDirection &other, const Unit &unit) const
MVDirection(const Quantity &angle0, const Quantity &angle1)
Creates the direction cosines from specified angles.
Double positionAngle(const MVDirection &other) const
MVDirection operator-(const MVDirection &right) const
Double positionAngle(const MVPosition &other) const
Get the position angle between the directions.
Quantity separation(const MVPosition &other, const Unit &unit) const
void shift(const MVDirection &shft, Bool trueAngle=False)
Double separation(const MVPosition &other) const
Get the angular separation between two directions.
void shiftAngle(const Quantum< Double > &off, const Quantum< Double > &pa)
Shift over an angle off in the direction pa.
Quantity getLat(const Unit &unit) const
and with specified units
Double separation(const MVDirection &other) const
void setAngle(Double angle0, Double angle1)
Set the internal value, using the longitude and latitude (in rad) given.
MVDirection operator+(const MVDirection &right) const
MVDirection()
Default constructor generates a direction to the pole (i.e.
MVDirection & operator+=(const MVDirection &right)
Addition and subtraction.
Vector< Double > get() const
Generate a 2-vector of angles (in rad).
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector<Quantity>.
void shiftLongitude(const Quantity &lng, Bool trueAngle=False)
MVDirection crossProduct(const MVDirection &other) const
Produce the cross product.
void shiftLongitude(Double lng, Bool trueAngle=False)
virtual Vector< Quantum< Double > > getXRecordValue() const
Double getLat() const
Get the latitude angle (rad).
virtual void adjust(Double &res)
Adjust the direction cosines to a length of 1 and return the length value.
void shift(const Quantum< Double > &lng, const Quantum< Double > &lat, Bool trueAngle=False)
Shift the direction in longitude (radians if Double) and/or latitude.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
MVDirection(const Quantity &angle0)
MVPosition()
Default constructor generates a (0,0,0) position.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
const Bool False
Definition aipstype.h:42
T & operator*()
Provide access to the field's value.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
Quantum< Double > Quantity
Definition Quantum.h:40
double Double
Definition aipstype.h:53