-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector2f.hpp
88 lines (65 loc) · 2.45 KB
/
vector2f.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef VECTOR2F_HPP_INCLUDED
#define VECTOR2F_HPP_INCLUDED
//Copyright (C) 2017 Mason Watmough
/*
This file is part of vector2f.
vector2f is free software: you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
vector2f is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with vector2f. If not, see <http://www.gnu.org/licenses/>.
*/
//#define VECTOR2F_USE_CUSTOM_SQRT //Uncomment this line to use custom sqrt function. May be faster on *some* hardware.
struct vector2f
{
float x, y;
vector2f(void);
vector2f(float, float);
vector2f operator+(vector2f);
vector2f operator+(float);
vector2f operator-(vector2f);
vector2f operator-(float);
vector2f operator*(vector2f);
vector2f operator*(float);
vector2f operator/(vector2f);
vector2f operator/(float);
vector2f operator-(void);
void operator+=(vector2f);
void operator+=(float);
void operator-=(vector2f);
void operator-=(float);
void operator*=(vector2f);
void operator*=(float);
void operator/=(vector2f);
void operator/=(float);
bool operator==(vector2f);
bool operator!=(vector2f);
static float Length(vector2f);
float Length(void);
static float LengthSq(vector2f);
float LengthSq(void);
static float Dot(vector2f, vector2f);
float Dot(vector2f);
static float Cross(vector2f, vector2f);
float Cross(vector2f);
static vector2f Normal(vector2f);
vector2f Normal(void);
static float Distance(vector2f, vector2f);
float Distance(vector2f);
static float DistanceSq(vector2f, vector2f);
float DistanceSq(vector2f);
static vector2f Project(vector2f, vector2f);
vector2f Project(vector2f);
static vector2f TangentL(vector2f);
vector2f TangentL(void);
static vector2f TangentR(vector2f);
vector2f TangentR(void);
static vector2f Rotation(vector2f, float);
vector2f Rotation(float);
};
#endif // VECTOR2F_HPP_INCLUDED