forked from vic4key/Vutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample.Math.h
More file actions
121 lines (99 loc) · 3.03 KB
/
Sample.Math.h
File metadata and controls
121 lines (99 loc) · 3.03 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
117
118
119
120
121
#pragma once
#include "Sample.h"
DEF_SAMPLE(Math)
{
std::cout << "GCD : " << vu::GCD(3, 9, 27, 81) << std::endl;
std::cout << "LCM : " << vu::LCM(3, 9, 27, 81) << std::endl;
{
vu::Point2DT<int> p1(1, 2), p2(3, 4), p3;
p3 = p1;
p3 == p1;
p3 != p2;
p3 += p1;
p3 -= p2;
p3 + p2;
p3 - p1;
p3.Translate(5, 6);
std::tcout << p1 << std::endl;
std::tcout << p2 << std::endl;
std::tcout << p3 << std::endl;
std::tcout << p1.Distance(p2) << std::endl;
std::tcout << p1.Midpoint(p2) << std::endl;
std::tcout << p1.Scale(2) << std::endl;
}
{
vu::Point3DT<int> p1(1, 2, 3), p2(4, 5, 6), p3;
p3 = p1;
p3 == p1;
p3 != p2;
p3 += p1;
p3 -= p2;
p3 + p2;
p3 - p1;
p3.Translate(7, 8, 9);
std::tcout << p1 << std::endl;
std::tcout << p2 << std::endl;
std::tcout << p3 << std::endl;
std::tcout << p1.Distance(p2) << std::endl;
std::tcout << p1.Midpoint(p2) << std::endl;
std::tcout << p1.Scale(2) << std::endl;
}
{
vu::Point4DT<int> p1(1, 2, 3, 4), p2(5, 6, 7, 8), p3;
p3 = p1;
p3 == p1;
p3 != p2;
p3 += p1;
p3 -= p2;
p3 + p2;
p3 - p1;
p3.Translate(3, 4, 5, 6);
std::tcout << p1 << std::endl;
std::tcout << p2 << std::endl;
std::tcout << p3 << std::endl;
std::tcout << p1.Distance(p2) << std::endl;
std::tcout << p1.Midpoint(p2) << std::endl;
std::tcout << p1.Scale(2) << std::endl;
}
{
vu::Vector2DT<double> v21(1, 2), v22(3, 4);
std::tcout << v21 << v22 << std::endl;
std::tcout << v21 + v22 << std::endl;
std::tcout << v21 - v22 << std::endl;
std::tcout << v21 * v22 << std::endl;
std::tcout << v21 / v22 << std::endl;
std::tcout << v21.Mag() << std::endl;
std::tcout << v21.Dot(v22) << std::endl;
std::tcout << v21.Cross(v22) << std::endl;
std::tcout << v21.Angle(v22) << std::endl;
std::tcout << v21.Normalize() << std::endl;
vu::Vector3DT<double> v31(1, 2, 3), v32(4, 5, 6);
std::tcout << v31 << v32 << std::endl;
std::tcout << v31 + v32 << std::endl;
std::tcout << v31 - v32 << std::endl;
std::tcout << v31 * v32 << std::endl;
std::tcout << v31 / v32 << std::endl;
std::tcout << v31.Mag() << std::endl;
std::tcout << v31.Dot(v32) << std::endl;
std::tcout << v31.Cross(v32) << std::endl;
std::tcout << v31.Angle(v32) << std::endl;
std::tcout << v31.Normalize() << std::endl;
vu::Vector4DT<double> v41(1, 2, 3, 4), v42(5, 6, 7, 8);
std::tcout << v41 << v42 << std::endl;
std::tcout << v41 + v42 << std::endl;
std::tcout << v41 - v42 << std::endl;
std::tcout << v41 * v42 << std::endl;
std::tcout << v41 / v42 << std::endl;
std::tcout << v41.Mag() << std::endl;
std::tcout << v41.Dot(v42) << std::endl;
// std::tcout << v41.Cross(v42) << std::endl;
std::tcout << v41.Angle(v42) << std::endl;
std::tcout << v41.Normalize() << std::endl;
}
{
vu::RectT<int> rect(100, 200);
rect.Center();
std::tcout << rect << std::endl;
}
return vu::VU_OK;
}