-
Notifications
You must be signed in to change notification settings - Fork 3
/
Line.hpp
68 lines (50 loc) · 1.13 KB
/
Line.hpp
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
#pragma once
#ifndef __MATHS_LINE_HPP__
#define __MATHS_LINE_HPP__
#include "Vector3.hpp"
namespace Math
{
class Line
{
public:
Vector3 start_point;
Vector3 end_point;
Line()
{
}
Line(const Vector3& start, const Vector3& end) : start_point(start), end_point(end)
{
}
Line(const Line& line) : start_point(line.start_point), end_point(line.end_point)
{
}
Line& operator = (const Line& line)
{
start_point = line.start_point;
end_point = line.end_point;
return *this;
}
bool operator == (const Line& line) const
{
return start_point == line.start_point && end_point == line.end_point;
}
bool operator != (const Line& line) const
{
return start_point != line.start_point || end_point != line.end_point;
}
float length() const;
float length_squared() const;
Vector3 vector() const
{
return end_point - start_point;
}
Vector3 direction() const;
Vector3 mid_point() const;
Vector3 point_at(float t) const
{
return Vector3::lerp(start_point, end_point, t);
}
void extend(float start_amount, float end_amount);
};
} // namespace Math
#endif // __MATHS_LINE_HPP__