-
Notifications
You must be signed in to change notification settings - Fork 9
/
Vertex3D.h
executable file
·118 lines (99 loc) · 3.21 KB
/
Vertex3D.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef _VERTEX3D_H
#define _VERTEX3D_H
#include <math.h>
#include "Vertex2D.h"
/// An inner-class, extending Vertex2D, representing a vertex in a triangle mesh
class Vertex3D : public Vertex2D
{
public:
///A constructor method
Vertex3D();
///A constructor method
Vertex3D(const Vertex3D& orig);
///A constructor method
/*!
* \param x a float argument, representing the x coordinate
* \param y a float argument, representing the y coordinate
* \param z a float argument, representing the z coordinate
*/
Vertex3D(double x, double y, double z);
///A destructor method
virtual ~Vertex3D();
///
friend bool operator== (const Vertex3D& p, const Vertex3D &q);
///
friend bool operator!= (const Vertex3D& p, const Vertex3D &q);
///A public method that returns the z coordinate
/*!
* \return a double value, representing the z coordinate
*/
double getZ();
///A public method that sets the x coordinate
/*!
* \param x a double argument, represents the value of the x coordinate to set
*/
void setZ(double x);
/**
* @brief norma
* @param v A 3D vertex
* @return The norm of the vector representing the vertex
*/
double norma(Vertex3D& v){return(sqrt(((v.getX()-x)*(v.getX()-x))+((v.getY()-y)*(v.getY()-y))+((v.getZ()-z)*(v.getZ()-z))));}
/**
* @brief prodscal
* @param v1 one vertex
* @param v2 another vertex
* @return Scalar product between this-v1 and this-v2
*/
double prodscal(Vertex3D& v1,Vertex3D& v2){return(((v1.getX()-x)*(v2.getX()-x))+((v1.getY()-y)*(v2.getY()-y))+((v1.getZ()-z)*(v2.getZ()-z)));}
//norm of this vector
double norma() {return sqrt((x)*(x)+(y)*(y)+(z)*(z));}
//scalar products between vectors vec and v1
double prodscal(Vertex3D& v1){return(((v1.getX())*(x))+((v1.getY())*(y))+((v1.getZ())*(z)));}
inline double distance(Vertex3D& v)
{
double xdist = this->x-v.getX();
double ydist = this->y-v.getY();
double zdist = this->z-v.getZ();
return sqrt(xdist*xdist + ydist*ydist + zdist*zdist);
}
/**
* @brief setSaliency
* @param sal saliency value to be set
*/
inline void setSaliency(double sal)
{
this->vertexSaliency = sal;
}
inline double saliency()
{
return this->vertexSaliency;
}
/**
* @brief operator <
* @param v A vertex
* @return
*/
inline bool operator<(Vertex3D& v){
if(this->x < v.getX()) return true;
else if(this->x == v.getX() && this->y < v.getY()) return true;
else if(this->x == v.getX() && this->y == v.getY() && this->z < v.getZ()) return true;
return false;
}
/**
* @brief operator >
* @param v A vertex
* @return
*/
inline bool operator>(Vertex3D& v){
if(this->x > v.getX()) return true;
else if(this->x == v.getX() && this->y > v.getY()) return true;
else if(this->x == v.getX() && this->y == v.getY() && this->z > v.getZ()) return true;
return false;
}
private:
///A protected variable representing the z coordinate of the point
double z;
double vertexSaliency;
};
#endif /* _VERTEX3D_H */