-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.cpp
More file actions
30 lines (22 loc) · 690 Bytes
/
Copy pathVertex.cpp
File metadata and controls
30 lines (22 loc) · 690 Bytes
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
//
// Created by raphael on 9/8/18.
//
#include "Vertex.h"
#include <math.h>
namespace rf {
Vertex::Vertex() = default;
Vertex::Vertex(sf::Vector2f v) : sf::Vector2f(v.x, v.y) {}
Vertex::Vertex(float x, float y) : Vector2(x, y) {}
float Vertex::dist(const Vertex other) const {
return sqrtf(powf(other.x - x, 2) + powf(other.y - y, 2));
}
float Vertex::magnitude() const {
return sqrtf(powf(x, 2) + powf(y, 2));
}
bool Vertex::within(const Vertex &min, const Vertex &max) const {
return x >= min.x && y >= min.y && x <= max.x && y <= max.y;
}
bool Vertex::completed() {
return angle >= M_PI * 2 - 0.1;
}
}