-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint3dw.h
94 lines (77 loc) · 2.03 KB
/
point3dw.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
86
87
88
89
90
91
92
93
94
#ifndef Point3dWW_H
#define Point3dWW_H
#include <point3d.h>
#include <vector3d.h>
#include <iostream>
class Point3dW
{
public:
Point3dW()
{
x = 0;
y = 0;
z = 0;
w = 0;
}
Point3dW(double _x, double _y, double _z,double _w)
{
x = _x;
y = _y;
z = _z;
w = _w;
}
~Point3dW()
{
}
void SetX(const double _x)
{
x = _x;
}
void SetY(const double _y)
{
y = _y;
}
void SetZ(const double _z)
{
z = _z;
}
void SetW(const double _w)
{
w = _w;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
double GetZ() const
{
return z;
}
double GetW() const
{
return w;
}
Point3d ToPoint3d(){
return Point3d(x/w,y/w,z/w);
}
Point3dW operator + (const Point3dW &v) const { return Point3dW(x+v.x, y+v.y, z+v.z,w); }
Point3dW operator + (const double &v) const { return Point3dW(x+v, y+v, z+v,w); }
Point3dW& operator += (const Point3dW &v) { x+=v.x; y+=v.y; z+=v.z; return *this; }
Point3dW operator - () const { return Point3dW(-x, -y, -z,w); }
Point3dW operator - (const Point3dW &v) const { return Point3dW(x-v.x, y-v.y, z-v.z,w); }
Point3dW& operator -= (const Point3dW &v) { x-=v.x; y-=v.y; z-=v.z; return *this; }
Point3dW operator * (double s) const { return Point3dW(x*s, y*s, z*s,w); }
Point3dW& operator *= (double s) { x*=s; y*=s; z*=s; return *this; }
Point3dW operator / (double s) const { return (*this)* (1/s); }
Point3dW& operator /= (double s) { return (*this)*=(1/s); }
Point3dW operator + (const Vector3d &v) {return Point3dW(x+v.X(), y+v.Y(), v.Z()+z,w);}
Vector3d operator - (const Point3dW &v) { return Vector3d(x-v.GetX(), y-v.GetY(), z-v.GetZ()); }
private:
//Eigen::Vector4d m_coord;
double x,y,z,w;
};
#endif // Point3dW_H