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
107public:
108
109 //# Friends
110
111 //# Constructors
112 // Default constructor generates a direction to the pole (i.e. (0,0,1))
114 // Creates from an MVPosition
115 MVDirection(const MVPosition &other);
116 // Constructs with elevation = 0.
117 // <group>
119 MVDirection(const Quantity &angle0);
120 // </group>
121 // Creates a specified vector
123 // Creates the direction cosines from specified angles along equator (azimuth)
124 // and towards pole (,elevation).
125 MVDirection(Double angle0, Double angle1);
126 // Creates the direction cosines from specified angles
127 // <thrown>
128 // <li> AipsError if quantities not in angle format
129 // </thrown>
130 // <group>
131 MVDirection(const Quantity &angle0, const Quantity &angle1);
132 // If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1);
133 // direction cosines assumed (if 3).
134 // <thrown>
135 // <li> AipsError if more than 3 values or incorrect units
136 // </thrown>
138 // </group>
139 // Create from Vector. Assumes angles if less than or equal than 2 elements.
140 // Assumes direction cosines if 3 elements.
141 // <thrown>
142 // <li> AipsError if more than 3 elements
143 // </thrown>
144 // <group>
147 // </group>
148
149 //# Operators
150 // Addition and subtraction
151 // <group>
153 MVDirection operator+(const MVDirection &right) const;
155 MVDirection operator-(const MVDirection &right) const;
156 // </group>
157
158 //# General Member Functions
159
160 // Tell me your type
161 // <group>
162 static void assure(const MeasValue &in);
163 // </group>
164
165 // Adjust the direction cosines to a length of 1
166 virtual void adjust();
167 // Adjust the direction cosines to a length of 1 and return the length value
168 virtual void adjust(Double &res);
169 // Re-adjust : taken from MVPosition.
170 //
171 // Clone data
172 virtual MeasValue *clone() const;
173 // Generate a 2-vector of angles (in rad)
175 // Get the latitude angle (rad)
176 Double getLat() const;
177 // and with specified units
178 Quantity getLat(const Unit &unit) const;
179 // Get the position angle between the directions. I.e. the angle between
180 // the direction from one to the pole, and from one to the other.
181 // <group>
182 Double positionAngle(const MVPosition &other) const;
183 Double positionAngle(const MVDirection &other) const;
185 const Unit &unit) const;
187 const Unit &unit) const;
188 // </group>
189 // Get the angular separation between two directions.
190 // <group>
191 Double separation(const MVPosition &other) const;
192 Double separation(const MVDirection &other) const;
194 const Unit &unit) const;
196 const Unit &unit) const;
197 // </group>
198 // Produce the cross product
200 // Get the internal value as a <src>Vector<Quantity></src>. Usable in
201 // records. The getXRecordValue() gets additional information for records.
202 // Note that the Vectors could be empty.
203 // <group>
207 // </group>
208 // Set the internal value if correct values and dimensions
209 virtual Bool putValue(const Vector<Quantum<Double> > &in);
210 // Set the internal value, using the longitude and latitude (in rad) given
211 void setAngle(Double angle0, Double angle1);
212 // Shift the direction in longitude (radians if Double) and/or latitude.
213 // If the trueAngle switch is True, the longitude shift will be in
214 // angular units perpendicular to the direction to the pole at the shifted
215 // latitude, along a great circle.
216 // <group>
217 void shift(const Quantum<Double> &lng,
218 const Quantum<Double> &lat, Bool trueAngle=False);
219 void shift(Double lng, Double lat, Bool trueAngle=False);
220 void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
221 void shiftLongitude(Double lng, Bool trueAngle=False);
222 void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
223 void shiftLatitude(Double lat, Bool trueAngle=False);
224 void shift(const MVDirection &shft, Bool trueAngle=False);
225 // </group>
226 // Shift over an angle off in the direction pa. pa is measured from North,
227 // in the direction of increasing longitude.
228 // <group>
230 const Quantum<Double> &pa);
232 // </group>
233
234protected:
235 //# Data
236};
237
238//# Global functions
239// Rotate a position vector
240MVDirection operator*(const RotMatrix &left, const MVDirection&right);
241MVDirection operator*(const MVDirection &left, const RotMatrix &right);
242
243
244} //# NAMESPACE CASACORE - END
245
246#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)
this file contains all the compiler specific defines
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
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53