summaryrefslogtreecommitdiffstats
path: root/Vertex.h
diff options
context:
space:
mode:
Diffstat (limited to 'Vertex.h')
-rw-r--r--Vertex.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/Vertex.h b/Vertex.h
index 665430d..801d029 100644
--- a/Vertex.h
+++ b/Vertex.h
@@ -1,21 +1,24 @@
#ifndef _VERTEX_H_
#define _VERTEX_H_
-class Vertex
+#include "Vector.h"
+
+class Vertex : public Vector
{
public:
- Vertex(float x0 = 0, float y0 = 0, float z0 = 0) : x(x0), y(y0), z(z0) {}
+ Vertex(float x0 = 0, float y0 = 0, float z0 = 0) : Vector(x0, y0, z0) {}
+ Vertex(const Vector &v) : Vector(v) {}
- float getX() const {return x;}
- float getY() const {return y;}
- float getZ() const {return z;}
-
float distanceSq(const Vertex &v) const {
- return x*v.x + y*v.y + z*v.z;
+ Vector delta = *this - v;
+
+ return delta.dot(delta);
+ }
+
+ Vector operator-(const Vertex &v) const {
+ return Vector(x-v.x, y-v.y, z-v.z);
}
- protected:
- float x, y, z;
};
#endif /*_VERTEX_H_*/