Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/coordConv/html/pvt_8h_source.html
Дата изменения: Thu May 7 21:42:46 2015
Дата индексирования: Sun Apr 10 01:18:34 2016
Кодировка:

Поисковые слова: п п п п п п п п
lsst.coordConv: include/coordConv/pvt.h Source File
lsst.coordConv  unknown
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
pvt.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 #include <string>
5 #include <iostream>
6 #include "coordConv/mathUtils.h"
7 
8 namespace coordConv {
9 
18  class PVT {
19  public:
20  double pos, vel, t;
21 
29  explicit PVT(double pos, double vel, double t)
30  :
31  pos(pos),
32  vel(vel),
33  t(t)
34  { };
35 
39  explicit PVT()
40  :
41  pos(DoubleNaN),
42  vel(DoubleNaN),
43  t(DoubleNaN)
44  { };
45 
47  PVT copy() const {
48  return PVT(pos, vel, t);
49  }
50 
52  PVT copy(double t) const {
53  return PVT(getPos(t), vel, t);
54  }
55 
57  double getPos(double t) const {
58  return pos + (vel * (t - this->t));
59  }
60 
62  void invalidate(double t = DoubleNaN) {
63  pos = DoubleNaN;
64  vel = DoubleNaN;
65  this->t = t;
66  }
67 
69  bool isfinite() const {
70  return std::isfinite(pos) && std::isfinite(vel) && std::isfinite(t);
71  }
72 
73  PVT & operator+=(PVT const &rhs) {
74  pos += rhs.getPos(t);
75  vel += rhs.vel;
76  return *this;
77  }
78 
79  PVT & operator-=(PVT const &rhs) {
80  pos -= rhs.getPos(t);
81  vel -= rhs.vel;
82  return *this;
83  }
84 
85  PVT & operator+=(double const &rhs) {
86  pos += rhs;
87  return *this;
88  }
89 
90  PVT & operator-=(double const &rhs) {
91  pos -= rhs;
92  return *this;
93  }
94 
95  PVT & operator*=(double const &rhs) {
96  pos *= rhs;
97  vel *= rhs;
98  return *this;
99  }
100 
101  PVT & operator/=(double const &rhs) {
102  pos /= rhs;
103  vel /= rhs;
104  return *this;
105  }
106 
107 
108  PVT operator+(PVT const &rhs) const {
109  PVT retVal(*this);
110  retVal += rhs;
111  return retVal;
112  }
113 
114  PVT operator-(PVT const &rhs) const {
115  PVT retVal(*this);
116  retVal -= rhs;
117  return retVal;
118  }
119 
120  PVT operator+(double const &rhs) const {
121  PVT retVal(*this);
122  retVal += rhs;
123  return retVal;
124  }
125 
126  PVT operator-(double const &rhs) const {
127  PVT retVal(*this);
128  retVal -= rhs;
129  return retVal;
130  }
131 
132  PVT operator*(double const &rhs) const {
133  PVT retVal(*this);
134  retVal *= rhs;
135  return retVal;
136  }
137 
138  PVT operator/(double const &rhs) const {
139  PVT retVal(*this);
140  retVal /= rhs;
141  return retVal;
142  }
143 
144  PVT operator-() const {
145  return PVT(-pos, -vel, t);
146  }
147 
148  bool operator==(PVT const &rhs) {
149  return (this->pos == rhs.pos) && (this->vel == rhs.vel) && (this->t == rhs.t);
150  }
151 
152  bool operator!=(PVT const &rhs) {
153  return !operator==(rhs);
154  }
155 
159  std::string __repr__() const;
160 
175  void setFromPair(double const posPair[2], double t, double deltaT, bool isAngle) {
176  pos = posPair[0];
177  if (isAngle) {
178  vel = coordConv::wrapCtr(posPair[1] - posPair[0]) / deltaT;
179  } else {
180  vel = (posPair[1] - posPair[0]) / deltaT;
181  }
182  this->t = t;
183  }
184  };
185 
197  bool polarFromXY(PVT &r, PVT &theta, PVT const &x, PVT const &y, double tai);
198 
208  void xyFromPolar(PVT &x, PVT &y, PVT const &r, PVT const &theta, double tai);
209 
228  void rot2D(PVT &rotX, PVT &rotY, PVT const &x, PVT const &y, double ang, double tai);
229 
233  inline PVT wrapPos(
234  PVT const &pvt
235  ) {
236  PVT ret = pvt;
237  ret.pos = coordConv::wrapPos(ret.pos);
238  return ret;
239  }
240 
244  inline PVT wrapCtr(
245  PVT const &pvt
246  ) {
247  PVT ret = pvt;
248  ret.pos = coordConv::wrapCtr(ret.pos);
249  return ret;
250  }
251 
264  std::ostream &operator<<(std::ostream &os, PVT const &pvt);
265 
266 }
PVT operator+(PVT const &rhs) const
Definition: pvt.h:108
PVT & operator+=(double const &rhs)
Definition: pvt.h:85
PVT operator-(PVT const &rhs) const
Definition: pvt.h:114
PVT copy(double t) const
Return a copy with a specified time.
Definition: pvt.h:52
void xyFromPolar(double &x, double &y, double r, double theta)
Definition: mathUtils.cc:28
bool operator!=(PVT const &rhs)
Definition: pvt.h:152
double t
Definition: pvt.h:20
double wrapCtr(double ang)
Definition: mathUtils.cc:33
PVT operator/(double const &rhs) const
Definition: pvt.h:138
const double DoubleNaN
Definition: mathUtils.h:16
std::string __repr__() const
Definition: pvt.cc:11
double vel
Definition: pvt.h:20
PVT(double pos, double vel, double t)
Definition: pvt.h:29
bool operator==(PVT const &rhs)
Definition: pvt.h:148
bool polarFromXY(double &r, double &theta, double x, double y)
Definition: mathUtils.cc:14
void setFromPair(double const posPair[2], double t, double deltaT, bool isAngle)
Definition: pvt.h:175
PVT operator*(double const &rhs) const
Definition: pvt.h:132
void rot2D(double &rotX, double &rotY, double x, double y, double ang)
Definition: mathUtils.cc:12
PVT copy() const
Return a copy.
Definition: pvt.h:47
double pos
Definition: pvt.h:20
double getPos(double t) const
Return the position at the specified time; return NaN if unknown.
Definition: pvt.h:57
PVT operator+(double const &rhs) const
Definition: pvt.h:120
PVT & operator-=(double const &rhs)
Definition: pvt.h:90
void invalidate(double t=DoubleNaN)
Set PVT invalid at the specified time (which defaults to NaN)
Definition: pvt.h:62
PVT operator-() const
Definition: pvt.h:144
PVT & operator+=(PVT const &rhs)
Definition: pvt.h:73
std::ostream & operator<<(std::ostream &out, Coord const &coord)
Definition: coord.cc:263
bool isfinite() const
Are all values finite? (Does it have finite pos, vel and t)?
Definition: pvt.h:69
PVT operator-(double const &rhs) const
Definition: pvt.h:126
PVT & operator*=(double const &rhs)
Definition: pvt.h:95
double wrapPos(double ang)
Definition: mathUtils.cc:20
PVT & operator-=(PVT const &rhs)
Definition: pvt.h:79
PVT & operator/=(double const &rhs)
Definition: pvt.h:101