-
Notifications
You must be signed in to change notification settings - Fork 0
/
leMath.h
71 lines (63 loc) · 1.52 KB
/
leMath.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <math.h>
#define Pi 3.14159265358979323846f
enum leObjectType { lePolygon,leEllipse};
struct leObjectID
{
unsigned int ID;
leObjectType type;
leObjectID(){}
~leObjectID(){}
leObjectID(unsigned int id,leObjectType t)
{
type = t;
ID = id;
}
};
float DtoR(float angle);
struct leVec2f
{
float x,y;
leVec2f(){}
leVec2f(float _x,float _y){x = _x;y = _y;}
~leVec2f(){};
leVec2f operator /(const float &scale) const; //Äåëèòü âåêòîð íà ñêàëÿðíîå ÷èñëî
leVec2f operator *(const leVec2f &other) const; //Óìíîæèòü âåêòîð íà âåêòîð
leVec2f operator +(const leVec2f &other) const; //Ïðèáàâèòü ê âåêòîðó âåêòîð
leVec2f operator -(const leVec2f &other) const; //Îòíÿòü âåêòîð
leVec2f operator -() const;
bool operator==(leVec2f &other) const;
bool operator>=(leVec2f &other) const;
bool operator<=(leVec2f &other) const;
bool operator <(leVec2f &other) const;
bool operator >(leVec2f &other) const;
bool operator!=(leVec2f &other) const;
void Scale(float size);//Óìíîæèòü âåêòîð íà ñêàëÿðíîå ÷èñëî !
float Length();// Äëèííà âåêòîðà
leVec2f Normal();
};
struct leEdge
{
unsigned int ID;
leVec2f v1;
leVec2f v2;
leVec2f LightVec1;
leVec2f LightVec2;
leObjectType type;
leEdge(){}
leEdge(leVec2f v_1,leVec2f v_2,leVec2f lpos, leObjectType t)
{
v1 = v_1;
v2 = v_2;
LightVec1 = v1 + (v1 - lpos) * leVec2f(110,110);
LightVec2 = v2 + (v2 - lpos) * leVec2f(100,100);
type = t;
}
~leEdge(){}
};
struct leAABB
{
leVec2f upperBound;
leVec2f lowerBound;
};
float dot(leVec2f v1,leVec2f v2);