summaryrefslogtreecommitdiffstats
path: root/Vertex3d.cpp
blob: 16c0e27080361875cb581cb4918c3cbb292f9424 (plain)
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
#include "Vertex3d.h"
#include <math.h>

float Vertex3d::distanceSq(const Vertex3d &v) const {
  return (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y) + (z - v.z)*(z - v.z);
}

float Vertex3d::distance(const Vertex3d &v) const {
  return sqrtf(distanceSq(v));
}


Vertex3d Vertex3d::operator+(const Vertex3d &v) const {
  return Vertex3d(x + v.x, y + v.y, z + v.z);
}

Vertex3d Vertex3d::operator-(const Vertex3d &v) const {
  return Vertex3d(x - v.x, y - v.y, z - v.z);
}

Vertex3d& Vertex3d::operator+=(const Vertex3d &v) {
  x += v.x;
  y += v.y;
  z += v.z;
  
  return *this;
}

Vertex3d& Vertex3d::operator-=(const Vertex3d &v) {
  x -= v.x;
  y -= v.y;
  z -= v.z;
  
  return *this;
}