casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVPosition.h
Go to the documentation of this file.
1 //# MVPosition.h: A 3D vector in space
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001
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_MVPOSITION_H
29 #define CASA_MVPOSITION_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
38 #include <casacore/casa/iosfwd.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 class RotMatrix;
44 
45 //# Constants (SUN compiler does not accept non-simple default arguments)
46 
47 // <summary> A 3D vector in space </summary>
48 
49 // <use visibility=export>
50 
51 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
52 // </reviewed>
53 
54 // <prerequisite>
55 // <li> <linkto class=MeasValue>MeasValue</linkto>
56 // <li> <linkto class=Vector>Vector</linkto>
57 // <li> <linkto class=Quantum>Quantum</linkto>
58 // </prerequisite>
59 //
60 // <etymology>
61 // From Measure, Value and Position
62 // </etymology>
63 //
64 // <synopsis>
65 // A MVPosition is a 3-vector of positions in a rectangular frame with
66 // internal units of m.<br>
67 // It can be constructed with:
68 // <ul>
69 // <li> MVPosition() creates point at origin (0,0,0)
70 // <li> MVPosition(MVPosition) creates a copy
71 // <li> MVPosition(Double, Double, Double) creates (x,y,z) with
72 // specified values
73 // <li> MVPosition(Quantity length,Double, Double) creates a MVPosition assuming
74 // that the two values are (in radians) angle along 'equator'
75 // and towards 'pole'. A length of zero will be made 1um.
76 // <li> MVPosition(Quantity length, Quantity, Quantity) creates a MVPosition
77 // assuming angles as in previous, or positions
78 // <li> <src>MVPosition(Quantity, Quantum<Vector<Double> >)</src> creates a
79 // MVPosition from angle vector, using first two angles, and
80 // assuming second as zero if not present, and pole if length 0.
81 // <li> <src>MVPosition(Quantum<Vector<Double> ></src> creates from
82 // angles or positions, depending on the units in the
83 // quantum vector. In the angle case,
84 // the data derived can be scaled with the readjust() function. If
85 // the unit of the quantum vector is length, position is
86 // assumed.
87 // <li> <src>MVPosition(Vector<Double></src> creates from angles (less than
88 // or equal to two elements) or x,y,z (3 elements).
89 // <li> <src>MVPosition(Vector<Quantity></src> creates from length+angles,
90 // angles, or x,y,z, depending on units.
91 // </ul>
92 // A void adjust(Double) function normalises the vector to a length of 1;
93 // a get() returns as a
94 // Double 3-vector the length and angles of the position vector;
95 // a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated
96 // element, and getValue returns the vector.<br>
97 // Positions can be added and subtracted.<br>
98 // The multiplication of two positions produces the in-product.<br>
99 // </synopsis>
100 //
101 // <example>
102 // See <linkto class=MPosition>Mposition</linkto> class.
103 // </example>
104 //
105 // <motivation>
106 // To do coordinate transformations
107 // </motivation>
108 //
109 // <todo asof="1996/02/04">
110 // <li> See if not better to have a direction + length
111 // </todo>
112 
113 class MVPosition : public MeasValue {
114 
115 public:
116  //# Constants
117  // Internal limts codes for negative height
118  // <group>
119  static const Double loLimit;
120  static const Double hiLimit;
121  // </group>
122  //# Friends
123 
124  //# Constructors
125  // Default constructor generates a (0,0,0) position
126  MVPosition();
127  // Copy constructor
128  MVPosition(const MVPosition &other);
129  // Creates a specified vector
130  MVPosition(Double in0, Double in1, Double in2);
131  // Creates a vector with specified length towards pole
132  // <group>
133  explicit MVPosition(Double in0);
134  MVPosition(const Quantity &l);
135  // </group>
136  // Creates the position from specified (azimuth,elevation) angles and length
137  MVPosition(const Quantity &l, Double angle0, Double angle1);
138  // Creates the position from specified angles and length. or positions
139  // <thrown>
140  // <li> AipsError if quantities not in angle format
141  // </thrown>
142  // <group>
143  MVPosition(const Quantity &l, const Quantity &angle0,
144  const Quantity &angle1);
145  // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
146  MVPosition(const Quantum<Vector<Double> > &angle);
147  MVPosition(const Quantity &l, const Quantum<Vector<Double> > &angle);
148  // </group>
149  // Create from specified length and/or angles and/or position
150  // <group>
151  explicit MVPosition(const Vector<Double> &other);
152  MVPosition(const Vector<Quantity> &other);
153  // </group>
154  // Copy assignment
155  MVPosition &operator=(const MVPosition &other);
156 
157  // Destructor
158  virtual ~MVPosition();
159 
160  //# Operators
161  // Multiplication defined as in-product
162  // <group>
163  Double operator*(const MVPosition &other) const;
164  // </group>
165 
166  // Equality comparisons
167  // <group>
168  Bool operator== (const MVPosition &other) const;
169  Bool operator!= (const MVPosition &other) const;
170  Bool near(const MVPosition &other, Double tol=1e-13) const;
171  Bool near(const MVPosition &other, Quantity tol) const;
172  Bool nearAbs(const MVPosition &other, Double tol=1e-13) const;
173  // </group>
174 
175  // Addition and subtraction
176  // <group>
177  MVPosition operator-() const;
178  MVPosition &operator+=(const MVPosition &right);
179  MVPosition operator+(const MVPosition &right) const;
180  MVPosition &operator-=(const MVPosition &right);
181  MVPosition operator-(const MVPosition &right) const;
182  // </group>
183 
184  // Multiplication with rotation matrix (see also global functions)
185  // <group>
186  MVPosition &operator*=(const RotMatrix &right);
187  // </group>
188 
189  // Multiplication with constant
190  // <group>
191  MVPosition &operator*=(Double right);
192  // </group>
193 
194  // Obtain an element
195  // <group>
196  Double &operator()(uInt which);
197  const Double &operator()(uInt which) const;
198  // </group>
199 
200  //# General Member Functions
201 
202  // Tell me your type
203  // <group>
204  virtual uInt type() const;
205  static void assure(const MeasValue &in);
206  // </group>
207 
208  // Normalise direction aspects by adjusting the length to 1
209  // <group>
210  // For position no adjustment; for direction adjustment
211  virtual void adjust();
212  // Adjustment with returned factor
213  virtual void adjust(Double &res);
214  // Re-adjust using factor given
215  virtual void readjust(Double res);
216  // </group>
217  // Get radius of position
218  virtual Double radius();
219  // Generate a 3-vector of coordinates (length(m), angles(rad))
220  Vector<Double> get() const;
221  // Generate a 3-vector of x,y,z in m
222  const Vector<Double> &getValue() const;
223  // Generate angle 2-vector (in rad)
225  // and with specified units
226  Quantum<Vector<Double> > getAngle(const Unit &unit) const;
227  // Get the longitudinal angle (in radians)
228  Double getLong() const;
229  // and with specified units
230  Quantity getLong(const Unit &unit) const;
231  // Get the latitude angle (rad)
232  Double getLat() const;
233  // and with specified units
234  Quantity getLat(const Unit &unit) const;
235  // Generate the length
236  Quantity getLength() const;
237  // and generate it with the specified units
238  Quantity getLength(const Unit &unit) const;
239  // Get the position angle between the directions. I.e. the angle between
240  // the direction from one to the pole, and from one to the other.
241  // <group>
242  Double positionAngle(const MVPosition &other) const;
243  Quantity positionAngle(const MVPosition &other,
244  const Unit &unit) const;
245  // </group>
246  // Get the angular separation between two directions.
247  // <group>
248  Double separation(const MVPosition &other) const;
249  Quantity separation(const MVPosition &other,
250  const Unit &unit) const;
251  // </group>
252  // Produce the cross product
253  MVPosition crossProduct(const MVPosition &other) const;
254 
255  // Print data
256  virtual void print(ostream &os) const;
257  // Clone
258  virtual MeasValue *clone() const;
259 
260  // Get the value in internal units
261  virtual Vector<Double> getVector() const;
262  // Set the value from internal units (set 0 for empty vector)
263  virtual void putVector(const Vector<Double> &in);
264  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
265  // records. The getXRecordValue() gets additional information for records.
266  // Note that the Vectors could be empty.
267  // <group>
268  virtual Vector<Quantum<Double> > getRecordValue() const;
269  virtual Vector<Quantum<Double> > getXRecordValue() const;
271  return getXRecordValue(); } ;
272  // </group>
273  // Set the internal value if correct values and dimensions
274  virtual Bool putValue(const Vector<Quantum<Double> > &in);
275 
276 protected:
277  //# Member functions
278  // Get the latitude assuming length is given
279  Double getLat(Double ln) const;
280  //# Data
281  // Position vector (in m)
283 };
284 
285 //# Global functions
286 // Rotate a position vector with rotation matrix and other multiplications
287 // <group>
288 MVPosition operator*(const RotMatrix &left, const MVPosition &right);
289 MVPosition operator*(const MVPosition &left, const RotMatrix &right);
290 MVPosition operator*(Double left, const MVPosition &right);
291 MVPosition operator*(const MVPosition &left, Double right);
292 Double operator*(const Vector<Double> &left, const MVPosition &right);
293 Double operator*(const MVPosition &left, const Vector<Double> &right);
294 // </group>
295 
296 
297 } //# NAMESPACE CASACORE - END
298 
299 #endif
virtual Double radius()
Get radius of position.
MVPosition & operator+=(const MVPosition &right)
virtual Vector< Double > getVector() const
Get the value in internal units.
virtual MeasValue * clone() const
Clone.
Double & operator()(uInt which)
Obtain an element.
Bool nearAbs(const MVPosition &other, Double tol=1e-13) const
virtual void adjust()
Normalise direction aspects by adjusting the length to 1.
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
virtual Vector< Quantum< Double > > getTMRecordValue() const
Definition: MVPosition.h:270
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.
virtual void print(ostream &os) const
Print data.
Bool near(const MVPosition &other, Double tol=1e-13) const
virtual uInt type() const
Tell me your type.
Double getLat() const
Get the latitude angle (rad)
static void assure(const MeasValue &in)
Bool operator!=(const MVPosition &other) const
Vector< Double > xyz
Position vector (in m)
Definition: MVPosition.h:282
virtual ~MVPosition()
Destructor.
A 3x3 rotation matrix.
Definition: RotMatrix.h:85
Double separation(const MVPosition &other) const
Get the angular separation between two directions.
MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right)
Rotate a EarthMagnetic vector with rotation matrix and other multiplications.
defines physical units
Definition: Unit.h:189
MVPosition & operator*=(const RotMatrix &right)
Multiplication with rotation matrix (see also global functions)
MVPosition()
Default constructor generates a (0,0,0) position.
Base class for values in a Measure.
Definition: MeasValue.h:107
double Double
Definition: aipstype.h:55
virtual Vector< Quantum< Double > > getXRecordValue() const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A 3D vector in space.
Definition: MVPosition.h:113
Double getLong() const
Get the longitudinal angle (in radians)
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
MVPosition crossProduct(const MVPosition &other) const
Produce the cross product.
const Double e
e and functions thereof:
Quantity getLength() const
Generate the length.
static const Double hiLimit
Definition: MVPosition.h:120
virtual void readjust(Double res)
Re-adjust using factor given.
const Vector< Double > & getValue() const
Generate a 3-vector of x,y,z in m.
MVPosition operator-() const
Addition and subtraction.
MVPosition operator+(const MVPosition &right) const
Bool operator==(const MVPosition &other) const
Equality comparisons.
MVPosition & operator-=(const MVPosition &right)
MVPosition & operator=(const MVPosition &other)
Copy assignment.
Double operator*(const MVPosition &other) const
Multiplication defined as in-product.
unsigned int uInt
Definition: aipstype.h:51
static const Double loLimit
Internal limts codes for negative height.
Definition: MVPosition.h:119
Quantum< Vector< Double > > getAngle() const
Generate angle 2-vector (in rad)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42