Instrument Neutral Distributed Interface INDI  2.0.2
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
119  {
120  return x * RHS.x + y * RHS.y + z * RHS.z;
121  }
122 
125  inline double Length() const
126  {
127  return sqrt(x * x + y * y + z * z);
128  }
129 
131  inline void Normalise()
132  {
133  double length = sqrt(x * x + y * y + z * z);
134  x /= length;
135  y /= length;
136  z /= length;
137  }
138 
143  void RotateAroundY(double Angle);
144 };
145 
152 {
155 
161  {
162  if (0 != PrivateDataSize)
163  {
164  PrivateData.reset(new unsigned char[PrivateDataSize]);
165  memcpy(PrivateData.get(), Source.PrivateData.get(), PrivateDataSize);
166  }
167  }
168 
171  {
174  Declination = RHS.Declination;
177  if (0 != PrivateDataSize)
178  {
179  PrivateData.reset(new unsigned char[PrivateDataSize]);
180  memcpy(PrivateData.get(), RHS.PrivateData.get(), PrivateDataSize);
181  }
182 
183  return *this;
184  }
185 
187 
191 
193  double Declination;
194 
198 
200  std::unique_ptr<unsigned char> PrivateData;
201 
204 };
205 
206 } // namespace AlignmentSubsystem
207 } // namespace INDI
The Angle class This class implements an angle type. This holds an angle that is always in the range ...
AlignmentPointSetEnum
The offsets to the fields in the alignment point set property.
Definition: Common.h:51
AlignmentDatabaseActions
Action to perform on Alignment Database.
Definition: Common.h:35
MountAlignment
Describe the alignment of a telescope axis. This is normally used to differentiate between equatorial...
Definition: Common.h:30
enum INDI::AlignmentSubsystem::MountAlignment MountAlignment_t
Namespace to encapsulate INDI client, drivers, and mediator classes.
Entry in the in memory alignment database.
Definition: Common.h:152
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
Definition: Common.h:190
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
Definition: Common.h:197
AlignmentDatabaseEntry()
Default constructor.
Definition: Common.h:154
AlignmentDatabaseEntry(const AlignmentDatabaseEntry &Source)
Copy constructor.
Definition: Common.h:157
const AlignmentDatabaseEntry & operator=(const AlignmentDatabaseEntry &RHS)
Override the assignment operator to provide a const version.
Definition: Common.h:170
double Declination
Declination in decimal degrees.
Definition: Common.h:193
int PrivateDataSize
This size in bytes of any private data.
Definition: Common.h:203
std::unique_ptr< unsigned char > PrivateData
Private data associated with this sync point.
Definition: Common.h:200
Holds a nomalised direction vector (direction cosines)
Definition: Common.h:69
double operator^(const TelescopeDirectionVector &RHS) const
Override the ^ operator to return a dot product.
Definition: Common.h:118
const TelescopeDirectionVector & operator*=(const double &RHS)
Override the *= operator to return a unary scalar product.
Definition: Common.h:103
const TelescopeDirectionVector operator-(const TelescopeDirectionVector &RHS) const
Override the - operator to return a binary vector subtract.
Definition: Common.h:112
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
TelescopeDirectionVector(double X, double Y, double Z)
Copy constructor.
Definition: Common.h:74
double Length() const
Return the length of the vector.
Definition: Common.h:125
const TelescopeDirectionVector operator*(const TelescopeDirectionVector &RHS) const
Override the * operator to return a cross product.
Definition: Common.h:81
TelescopeDirectionVector()
Default constructor.
Definition: Common.h:71
const TelescopeDirectionVector operator*(const double &RHS) const
Override the * operator to return a scalar product.
Definition: Common.h:92
void Normalise()
Normalise the vector.
Definition: Common.h:131