1 | #include <vec/vec3.hfa> |
---|
2 | #include <fstream.hfa> |
---|
3 | #include <limits.hfa> |
---|
4 | |
---|
5 | int main(void) { |
---|
6 | vec3(int) v1 = {1,2,3}; |
---|
7 | sout | "ctor(x,y):" | v1; |
---|
8 | |
---|
9 | vec3(int) v2 = v1; |
---|
10 | sout | "copy ctor:" | v2; |
---|
11 | |
---|
12 | { |
---|
13 | vec3(int) u = {11, -5, 7}; |
---|
14 | vec3(int) v = {2, 3, 7}; |
---|
15 | sout | "?/?(vec)" | (u / v); |
---|
16 | sout | "?/=?(vec)" | (u /= v); |
---|
17 | } |
---|
18 | |
---|
19 | { |
---|
20 | vec3(int) u = {1, -3, 100}; |
---|
21 | sout | "++?" | ++u; |
---|
22 | } |
---|
23 | |
---|
24 | { |
---|
25 | vec3(int) u = {1, -3, 100}; |
---|
26 | sout | "--?" | --u; |
---|
27 | } |
---|
28 | { |
---|
29 | vec3(int) u = {1, -3, 100}; |
---|
30 | sout | "?++(part 1)" | u++; |
---|
31 | sout | "?++(part 2)" | u; |
---|
32 | } |
---|
33 | { |
---|
34 | vec3(int) u = {1, -3, 100}; |
---|
35 | sout | "?--(part 1)" | u--; |
---|
36 | sout | "?--(part 2)" | u; |
---|
37 | } |
---|
38 | |
---|
39 | // % |
---|
40 | { |
---|
41 | vec3(int) u = {-12, 123, 100}; |
---|
42 | sout | "?%?(int)" | (u % 2); |
---|
43 | sout | "?%=?(int)" | (u %= 2); |
---|
44 | } |
---|
45 | { |
---|
46 | vec3(int) u = {-12, 27, 100}; |
---|
47 | vec3(int) v = {5, 4, 13}; |
---|
48 | sout | "?%?(vec)" | (u % v); |
---|
49 | sout | "?%=?(vec)" | (u %= v); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | // & |
---|
54 | { |
---|
55 | vec3(int) u = {5, 1, 8}; |
---|
56 | sout | "?&?(int)" | (u & (1 << 3)); |
---|
57 | sout | "?&=?(int)" | (u &= (1 << 3)); |
---|
58 | } |
---|
59 | { |
---|
60 | vec3(int) u = {5, 6, 5}; |
---|
61 | vec3(int) v = {3, 7, 3}; |
---|
62 | sout | "?&?(vec)" | (u & v); |
---|
63 | sout | "?&=?(vec)" | (u &= v); |
---|
64 | } |
---|
65 | |
---|
66 | // | |
---|
67 | { |
---|
68 | vec3(int) u = {5, 1, 5}; |
---|
69 | sout | "?|?(int)" | (u | 2); |
---|
70 | sout | "?|=?(int)" | (u |= 2); |
---|
71 | } |
---|
72 | { |
---|
73 | vec3(int) u = {5, 1, 5}; |
---|
74 | vec3(int) v = {2, 1, 2}; |
---|
75 | sout | "?|?(vec)" | (u | v); |
---|
76 | sout | "?|=?(vec)" | (u |= v); |
---|
77 | } |
---|
78 | |
---|
79 | // ^ |
---|
80 | { |
---|
81 | vec3(int) u = {9, 5, 8}; |
---|
82 | sout | "?^?(int)" | (u ^ 5); |
---|
83 | sout | "?^=?(int)" | (u ^= 5); |
---|
84 | } |
---|
85 | { |
---|
86 | vec3(int) u = {9, 5, 8}; |
---|
87 | vec3(int) v = {5, 0, 1}; |
---|
88 | sout | "?^?(vec)" | (u ^ v); |
---|
89 | sout | "?^=?(vec)" | (u ^= v); |
---|
90 | } |
---|
91 | |
---|
92 | // << |
---|
93 | { |
---|
94 | vec3(int) u = {2, 1, 4}; |
---|
95 | sout | "?<<?(int)" | (u << 1); |
---|
96 | sout | "?<<=?(int)" | (u <<= 1); |
---|
97 | } |
---|
98 | { |
---|
99 | vec3(int) u = {1, 1, 1}; |
---|
100 | vec3(int) v = {5, 2, 1}; |
---|
101 | sout | "?<<?(vec)" | (u << v); |
---|
102 | sout | "?<<=?(vec)" | (u <<= v); |
---|
103 | } |
---|
104 | |
---|
105 | // >> |
---|
106 | { |
---|
107 | vec3(int) u = {2, 1, 4}; |
---|
108 | sout | "?>>?(int)" | (u >> 1); |
---|
109 | sout | "?>>=?(int)" | (u >>= 1); |
---|
110 | } |
---|
111 | { |
---|
112 | vec3(int) u = {5, 7, 8}; |
---|
113 | vec3(int) v = {1, 2, 2}; |
---|
114 | sout | "?>>?(vec)" | (u >> v); |
---|
115 | sout | "?>>=?(vec)" | (u >>= v); |
---|
116 | } |
---|
117 | |
---|
118 | // ~ |
---|
119 | { |
---|
120 | vec3(int) u = {5, 2, 1}; |
---|
121 | sout | "~?" | (~u); |
---|
122 | } |
---|
123 | |
---|
124 | v1 = (vec3(int)){2, 3, 4}; |
---|
125 | v2 = (vec3(int)){13, 2, -7}; |
---|
126 | sout | "dot:" | dot(v1, v2); |
---|
127 | |
---|
128 | v1 = (vec3(int)){2,3,4}; |
---|
129 | sout | "length_squared:" | length_squared(v1); |
---|
130 | } |
---|