-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec2.h
52 lines (46 loc) · 1.03 KB
/
vec2.h
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
#ifndef VEC2
#define VEC2
#include <cmath>
#include <array>
class vec2
{
public:
float X;
float Y;
vec2();
vec2(std::array<float,2> vec);
vec2(float X,float Y);
std::array<float,2> toarr() const;
float abs() const;
float abspow2() const;
float angle() const;
float distTo(const vec2 &b) const;
float angTo(const vec2 &b) const;
float xTo(const vec2 &b) const;
vec2 project(vec2 b) const;
void rotate(float Angle);
vec2 & operator+=(const vec2 & b);
vec2 & operator-=(const vec2 & b);
vec2 & operator*=(float f);
};
vec2 operator+(vec2 lhs,const vec2 & rhs);
vec2 operator-(vec2 lhs,const vec2 & rhs);
vec2 operator*(float rhs,vec2 lhs);
float operator*(const vec2 & lhs,const vec2 & rhs);
vec2 eR(float angle);
class mat2
{
public:
float a;
float b;
float c;
float d;
mat2(float a,float b,float c, float d);
mat2(const vec2 & A,const vec2 & B);
mat2 inv() const;
mat2 T() const;
float det() const;
};
vec2 operator*(const mat2 & M,const vec2 & x);
std::array<float,3> vec2sec(vec2 A,vec2 B,vec2 C,vec2 D);
#endif