-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredmath.hpp
More file actions
116 lines (94 loc) · 2.78 KB
/
redmath.hpp
File metadata and controls
116 lines (94 loc) · 2.78 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef REDMATH_HPP
#define REDMATH_HPP
#include <math.h>
namespace math_op
{
static const double PI_s = 3.1415;
static const double PI = 3.141592653589793;
class Vector2
{
public:
double x;
double y;
Vector2();
Vector2(double v[2]);
Vector2(double xv, double yv);
Vector2 & operator = (Vector2 other);
/* DIV & MUL */
Vector2* operator*(Vector2& rht);
Vector2* operator*=(double num);
Vector2* operator/(Vector2& rht);
Vector2& operator/=(double num);
/* SUB & SUM */
Vector2* operator+(Vector2 & rht);
Vector2* operator-(Vector2 & rht);
/* COMP */
bool operator==(Vector2 & val);
void Rotate(Vector2 point, double angle);
void Rotate(double angle);
double GetAngle();
double Size();
Vector2* Normalize();
/* Popular Vector2 const */
static const Vector2 Left;
static const Vector2 Right;
static const Vector2 Up;
static const Vector2 Down;
static const Vector2 Zero;
static const Vector2 One;
};
class Vector3
{
public:
double x;
double y;
double z;
Vector3();
Vector3(double v[3]);
Vector3(double xv, double yv, double zv);
Vector3 & operator = (Vector3 other);
/* DIV & MUL */
Vector3* operator*(Vector3& rht);
Vector3* operator*=(double num);
Vector3* operator/(Vector3& rht);
Vector3& operator/=(double num);
/* SUB & SUM */
Vector3* operator+(Vector3 & rht);
Vector3* operator-(Vector3 & rht);
/* COMP */
bool operator==(Vector3 & val);
double Size();
Vector3* Normalize();
/* Popular Vector2 const */
static const Vector3 Left;
static const Vector3 Right;
static const Vector3 Up;
static const Vector3 Down;
static const Vector3 Forward;
static const Vector3 Backward;
static const Vector3 Zero;
static const Vector3 One;
};
class Line{
public:
Vector2 from;
Vector2 to;
Line(double v1[2], double v2[2]);
Line(double coord[4]);
Line(double x1, double y1, double x2, double y2);
Line(Vector2 _from, Vector2 _to);
double Size();
void Rotate(Vector2 point, double angle);
Vector2 GetCenter();
Line* Normalize();
Vector2 Direction();
void Move(Vector2 tv);
};
unsigned int GetFactorial(unsigned int number);
namespace geom
{
double area_of_polygon_inside_circle(double circle_radius, int number_sides);
double area_of_circle(double circle_radius);
}
}
#endif // REDMATH_HPP