-
Notifications
You must be signed in to change notification settings - Fork 0
/
Coordinate.h
85 lines (73 loc) · 2.52 KB
/
Coordinate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef COORDINATE_H_
#define COORDINATE_H_
#include <cmath>
#include <iostream>
/*
* "Coordinate" - Hugo Buddelmeijer 20051001
* This class contains a 3Dimensional coordinate, it can be
* set and read in Cartesian or Spherical coordinates.
* If it is set in one coordinate system, the
* other coordinates are set to NaN. When a coordinate is
* read from another system, the coordinates are converted.
* This way coordinate transformations are only performed
* when nescecary.
*/
class Coordinate
{
public:
Coordinate();
virtual ~Coordinate();
// Cartesian
Coordinate & cartesian(double pX, double pY, double pZ);
double cartesianX(); // returns X
double cartesianX(double pX); // sets X
double cartesianY();
double cartesianY(double pY);
double cartesianZ();
double cartesianZ(double pZ);
// Spherical
Coordinate & spherical(double pRadius, double pZenith, double pAzimuth);
double sphericalRadius(); // returns radius
double sphericalRadius(double pSr); // sets radius
double sphericalZenith(); // returns zenith
double sphericalZenith(double pSze);
double sphericalAzimuth(); // returns azimuth
double sphericalAzimuth(double pSaz);
double sphericalLatitude();
double sphericalLatitude(double pSla);
double sphericalAitoffX();
double sphericalAitoffY();
double sphericalAitoffX2();
double sphericalAitoffY2();
void convertCartesianToSpherical();
void convertSphericalToCartesian();
// shorthands inline
// carthesian
double x(){return cartesianX();}
double x(double px){return cartesianX(px);}
double y(){return cartesianY();}
double y(double py){return cartesianY(py);}
double z(){return cartesianZ();}
double z(double pz){return cartesianZ(pz);}
// spherical
double ra(){return sphericalRadius();}
double ra(double pr){return sphericalRadius(pr);}
double ze(){return sphericalZenith();}
double ze(double pr){return sphericalZenith(pr);}
double az(){return sphericalAzimuth();}
double az(double pr){return sphericalAzimuth(pr);}
void clearCartesian();
void clearSpherical();
private:
double circ; // two*pi
// Cartesian
double mCartesianX;
double mCartesianY;
double mCartesianZ;
// Spherical
double mSphericalRadius;
double mSphericalZenith; //or colatitude or polar_angle
double mSphericalAzimuth; // or longitude
//double mSpherLatitude; // = circ/4 - zenith
};
#endif /*COORDINATE_H_*/