Instrument Neutral Distributed Interface INDI  1.9.5
Common.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <cstring>
12 #include <cmath>
13 #include <memory>
14 
16 
17 namespace INDI
18 {
24 namespace AlignmentSubsystem
25 {
31 
35 {
45 };
46 
51 {
58 };
59 
69 {
71  TelescopeDirectionVector() : x(0), y(0), z(0) {}
72 
74  TelescopeDirectionVector(double X, double Y, double Z) : x(X), y(Y), z(Z) {}
75 
76  double x;
77  double y;
78  double z;
79 
82  {
84 
85  Result.x = y * RHS.z - z * RHS.y;
86  Result.y = z * RHS.x - x * RHS.z;
87  Result.z = x * RHS.y - y * RHS.x;
88  return Result;
89  }
90 
92  inline const TelescopeDirectionVector operator*(const double &RHS) const
93  {
95 
96  Result.x = x * RHS;
97  Result.y = y * RHS;
98  Result.z = z * RHS;
99  return Result;
100  }
101 
103  inline const TelescopeDirectionVector &operator*=(const double &RHS)
104  {
105  x *= RHS;
106  y *= RHS;
107  z *= RHS;
108  return *this;
109  }
110 
113  {
114  return TelescopeDirectionVector(x - RHS.x, y - RHS.y, z - RHS.z);
115  }
116 
118  inline double operator^(const TelescopeDirectionVector &RHS) const { return x * RHS.x + y * RHS.y + z * RHS.z; }
119 
122  inline double Length() const { return sqrt(x * x + y * y + z * z); }
123 
125  inline void Normalise()
126  {
127  double length = sqrt(x * x + y * y + z * z);
128  x /= length;
129  y /= length;
130  z /= length;
131  }
132 
137  void RotateAroundY(double Angle);
138 };
139 
146 {
149 
155  {
156  if (0 != PrivateDataSize)
157  {
158  PrivateData.reset(new unsigned char[PrivateDataSize]);
159  memcpy(PrivateData.get(), Source.PrivateData.get(), PrivateDataSize);
160  }
161  }
162 
165  {
168  Declination = RHS.Declination;
171  if (0 != PrivateDataSize)
172  {
173  PrivateData.reset(new unsigned char[PrivateDataSize]);
174  memcpy(PrivateData.get(), RHS.PrivateData.get(), PrivateDataSize);
175  }
176 
177  return *this;
178  }
179 
181 
185 
187  double Declination;
188 
192 
194  std::unique_ptr<unsigned char> PrivateData;
195 
198 };
199 
200 } // namespace AlignmentSubsystem
201 } // namespace INDI
INDI::AlignmentSubsystem::ZENITH
@ ZENITH
Definition: Common.h:30
INDI::AlignmentSubsystem::ENTRY_VECTOR_Z
@ ENTRY_VECTOR_Z
Definition: Common.h:57
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::TelescopeDirection
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
Definition: Common.h:191
INDI::AlignmentSubsystem::AlignmentDatabaseEntry
Entry in the in memory alignment database.
Definition: Common.h:145
INDI::AlignmentSubsystem::INSERT
@ INSERT
Definition: Common.h:37
INDI::AlignmentSubsystem::MountAlignment
MountAlignment
Describe the alignment of a telescope axis. This is normally used to differentiate between equatorial...
Definition: Common.h:30
INDI::AlignmentSubsystem::LOAD_DATABASE
@ LOAD_DATABASE
Definition: Common.h:43
INDI::AlignmentSubsystem::SOUTH_CELESTIAL_POLE
@ SOUTH_CELESTIAL_POLE
Definition: Common.h:30
INDI::AlignmentSubsystem::READ_INCREMENT
@ READ_INCREMENT
Definition: Common.h:42
INDI::AlignmentSubsystem::TelescopeDirectionVector::operator*
const TelescopeDirectionVector operator*(const TelescopeDirectionVector &RHS) const
Override the * operator to return a cross product.
Definition: Common.h:81
INDI::AlignmentSubsystem::ENTRY_RA
@ ENTRY_RA
Definition: Common.h:53
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateDataSize
int PrivateDataSize
This size in bytes of any private data.
Definition: Common.h:197
INDI::AlignmentSubsystem::ENTRY_DEC
@ ENTRY_DEC
Definition: Common.h:54
INDI::AlignmentSubsystem::TelescopeDirectionVector::TelescopeDirectionVector
TelescopeDirectionVector()
Default constructor.
Definition: Common.h:71
INDI::AlignmentSubsystem::NORTH_CELESTIAL_POLE
@ NORTH_CELESTIAL_POLE
Definition: Common.h:30
INDI::AlignmentSubsystem::ENTRY_VECTOR_X
@ ENTRY_VECTOR_X
Definition: Common.h:55
INDI::AlignmentSubsystem::EDIT
@ EDIT
Definition: Common.h:38
INDI::AlignmentSubsystem::APPEND
@ APPEND
Definition: Common.h:36
INDI::AlignmentSubsystem::ENTRY_VECTOR_Y
@ ENTRY_VECTOR_Y
Definition: Common.h:56
Angle
The Angle class This class implements an angle type. This holds an angle that is always in the range ...
Definition: scopesim_helper.h:50
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::AlignmentDatabaseEntry
AlignmentDatabaseEntry(const AlignmentDatabaseEntry &Source)
Copy constructor.
Definition: Common.h:151
INDI::AlignmentSubsystem::AlignmentPointSetEnum
AlignmentPointSetEnum
The offsets to the fields in the alignment point set property.
Definition: Common.h:50
INDI::AlignmentSubsystem::TelescopeDirectionVector::operator-
const TelescopeDirectionVector operator-(const TelescopeDirectionVector &RHS) const
Override the - operator to return a binary vector subtract.
Definition: Common.h:112
INDI::AlignmentSubsystem::CLEAR
@ CLEAR
Definition: Common.h:40
INDI::AlignmentSubsystem::TelescopeDirectionVector::operator^
double operator^(const TelescopeDirectionVector &RHS) const
Override the ^ operator to return a dot product.
Definition: Common.h:118
INDI::AlignmentSubsystem::AlignmentDatabaseActions
AlignmentDatabaseActions
Action to perform on Alignment Database.
Definition: Common.h:34
INDI::AlignmentSubsystem::DELETE
@ DELETE
Definition: Common.h:39
INDI::AlignmentSubsystem::TelescopeDirectionVector::z
double z
Definition: Common.h:78
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::AlignmentDatabaseEntry
AlignmentDatabaseEntry()
Default constructor.
Definition: Common.h:148
INDI::AlignmentSubsystem::TelescopeDirectionVector::operator*
const TelescopeDirectionVector operator*(const double &RHS) const
Override the * operator to return a scalar product.
Definition: Common.h:92
INDI::AlignmentSubsystem::READ
@ READ
Definition: Common.h:41
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateData
std::unique_ptr< unsigned char > PrivateData
Private data associated with this sync point.
Definition: Common.h:194
INDI::AlignmentSubsystem::TelescopeDirectionVector::RotateAroundY
void RotateAroundY(double Angle)
Rotate the reference frame around the Y axis. This has the affect of rotating the vector itself in th...
Definition: Common.cpp:18
INDI::AlignmentSubsystem::TelescopeDirectionVector::operator*=
const TelescopeDirectionVector & operator*=(const double &RHS)
Override the *= operator to return a unary scalar product.
Definition: Common.h:103
INDI::AlignmentSubsystem::TelescopeDirectionVector::y
double y
Definition: Common.h:77
INDI::AlignmentSubsystem::ENTRY_OBSERVATION_JULIAN_DATE
@ ENTRY_OBSERVATION_JULIAN_DATE
Definition: Common.h:52
INDI::AlignmentSubsystem::TelescopeDirectionVector::Length
double Length() const
Return the length of the vector.
Definition: Common.h:122
INDI::AlignmentSubsystem::TelescopeDirectionVector::TelescopeDirectionVector
TelescopeDirectionVector(double X, double Y, double Z)
Copy constructor.
Definition: Common.h:74
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::Declination
double Declination
Declination in decimal degrees.
Definition: Common.h:187
INDI::AlignmentSubsystem::MountAlignment_t
enum INDI::AlignmentSubsystem::MountAlignment MountAlignment_t
INDI::AlignmentSubsystem::SAVE_DATABASE
@ SAVE_DATABASE
Definition: Common.h:44
INDI::AlignmentSubsystem::TelescopeDirectionVector::Normalise
void Normalise()
Normalise the vector.
Definition: Common.h:125
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::RightAscension
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
Definition: Common.h:184
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::ObservationJulianDate
double ObservationJulianDate
Definition: Common.h:180
INDI::AlignmentSubsystem::TelescopeDirectionVector::x
double x
Definition: Common.h:76
INDI::AlignmentSubsystem::TelescopeDirectionVector
Holds a nomalised direction vector (direction cosines)
Definition: Common.h:68
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::operator=
const AlignmentDatabaseEntry & operator=(const AlignmentDatabaseEntry &RHS)
Override the assignment operator to provide a const version.
Definition: Common.h:164