cryph utilities [subset]  2.0
Subset of the full cryph package of mathematical utilities for points, vectors, and matrices
ProjPoint.h
Go to the documentation of this file.
1 
7 #ifndef PROJPOINT_H
8 #define PROJPOINT_H
9 
10 #include "AffPoint.h"
11 
12 namespace cryph
13 {
14 
15 class ProjPoint
16 {
17 public:
19  ProjPoint();
20 
24  ProjPoint(const ProjPoint& p);
25 
31  ProjPoint(const AffPoint& p, double w=1.0);
32 
38  ProjPoint(const double* p);
39 
45  ProjPoint(const float* p);
46 
54  ProjPoint(double xx, double yy, double zz=0.0, double ww=1.0);
55 
57  virtual ~ProjPoint();
58 
63  ProjPoint operator=(const ProjPoint& rhs);
64 
69  ProjPoint operator+=(const ProjPoint& rhs);
70 
75  ProjPoint operator*=(double f);
76 
81  ProjPoint operator/=(double f);
82 
88  double operator[](int index) const;
89 
95  ProjPoint operator+(const ProjPoint& p2) const
96  { return ProjPoint(x+p2.x, y+p2.y, z+p2.z, w+p2.w); }
97 
103  ProjPoint operator-(const ProjPoint& p2) const
104  { return ProjPoint(x-p2.x, y-p2.y, z-p2.z, w-p2.w); }
105 
111  ProjPoint operator*(double f) const
112  { return ProjPoint(f*x, f*y, f*z, f*w); }
113 
119  ProjPoint operator/(double f) const
120  { return ProjPoint(x/f, y/f, z/f, w/f); }
121 
131  double* aCoords(double coords[], int offset=0) const;
132 
143  double* aCoords(double coords[][3], int offset=0) const;
144 
154  float* aCoords(float coords[], int offset=0) const;
155 
166  float* aCoords(float coords[][3], int offset=0) const;
167 
172  void aCoords(AffPoint& aPnt) const // ... into an AffPoint
173  { aPnt = AffPoint(x/w, y/w, z/w); }
174 
178  AffPoint aCoords() const // ... into an AffPoint
179  { return AffPoint(x/w, y/w, z/w); }
180 
190  double* pCoords(double* coords, int offset=0) const;
191 
202  double* pCoords(double coords[][4], int offset=0) const;
203 
213  float* pCoords(float* coords, int offset=0) const;
214 
225  float* pCoords(float coords[][4], int offset=0) const;
226 
241  void swizzle(char xyzw[4]);
242 
243  // Coordinates are public, but you should try to use direct access
244  // to these only for simple alteration of coordinates. Otherwise
245  // use public methods.
246  double x;
247  double y;
248  double z;
249  double w;
250 };
251 
252 std::ostream& operator<<(std::ostream& os, const ProjPoint& p);
253 std::istream& operator>>(std::istream& is, ProjPoint& p);
254 
255 static ProjPoint operator*(double f, const ProjPoint& p)
256  { return ProjPoint(f*p[X],f*p[Y],f*p[Z],f*p[W]); }
257 }
258 
259 #endif
Definition: ProjPoint.h:15
Definition: AffPoint.c++:12
double w
Definition: ProjPoint.h:249
ProjPoint()
Definition: ProjPoint.c++:15
ProjPoint operator*=(double f)
Definition: ProjPoint.c++:97
double x
Definition: ProjPoint.h:246
AffPoint aCoords() const
Definition: ProjPoint.h:178
double operator[](int index) const
Definition: ProjPoint.c++:110
double z
Definition: ProjPoint.h:248
ProjPoint operator/=(double f)
Definition: ProjPoint.c++:103
ProjPoint operator/(double f) const
Definition: ProjPoint.h:119
double * pCoords(double *coords, int offset=0) const
Definition: ProjPoint.c++:144
ProjPoint operator+(const ProjPoint &p2) const
Definition: ProjPoint.h:95
virtual ~ProjPoint()
Definition: ProjPoint.c++:41
ProjPoint operator=(const ProjPoint &rhs)
Definition: ProjPoint.c++:85
ProjPoint operator*(double f) const
Definition: ProjPoint.h:111
void aCoords(AffPoint &aPnt) const
Definition: ProjPoint.h:172
ProjPoint operator+=(const ProjPoint &rhs)
Definition: ProjPoint.c++:91
double y
Definition: ProjPoint.h:247
ProjPoint operator-(const ProjPoint &p2) const
Definition: ProjPoint.h:103
void swizzle(char xyzw[4])
Definition: ProjPoint.c++:180
Definition: AffPoint.h:25