1 | #include "../../libcfa/src/vec/vec2.hfa" |
---|
2 | #include <fstream.hfa> |
---|
3 | |
---|
4 | int main(void) { |
---|
5 | vec2(float) v1 = {1.f,2.f}; |
---|
6 | sout | "ctor(x,y):" | v1; |
---|
7 | |
---|
8 | vec2(float) v2 = v1; |
---|
9 | sout | "copy ctor:" | v2; |
---|
10 | |
---|
11 | v2 = (vec2(float)){3.f, 4.2f}; |
---|
12 | sout | "assignment:" | v2; |
---|
13 | |
---|
14 | v2 = v1; |
---|
15 | sout | "move assignment:" | v2; |
---|
16 | |
---|
17 | vec2(float) v3 = 0; |
---|
18 | sout | "zero-init:" | v3; |
---|
19 | |
---|
20 | v1 = 0; |
---|
21 | sout | "zero-assign:" | v1; |
---|
22 | |
---|
23 | vec2(float) v4 = {1.23f}; |
---|
24 | sout | "fill-ctor:" | v4; |
---|
25 | |
---|
26 | v1 = (vec2(float)){1.23f, 3.43f}; |
---|
27 | sout | "?-?:" | (v1 - (vec2(float)){1.21f,3}); |
---|
28 | |
---|
29 | v1 -= (vec2(float)){-2, 10}; |
---|
30 | sout | "?-=?:" | v1; |
---|
31 | |
---|
32 | v1 = -v1; |
---|
33 | sout | "-?:" | v1; |
---|
34 | |
---|
35 | v1 = (vec2(float)){1.5f, 2.75f}; |
---|
36 | sout | "?+?:" | (v1 + (vec2(float)){0.8f, -0.3f}); |
---|
37 | |
---|
38 | v1 += (vec2(float)){0.8f, -0.3f}; |
---|
39 | sout | "?+=?:" | v1; |
---|
40 | |
---|
41 | v1 = (vec2(float)){1.5f, 2.75f}; |
---|
42 | sout | "v*s:" | v1 * 3.f; |
---|
43 | |
---|
44 | sout | "s*v:" | 3.f * v1; |
---|
45 | |
---|
46 | v1 *= 3; |
---|
47 | sout | "?*=?:" | v1; |
---|
48 | |
---|
49 | v1 = (vec2(float)){2, -0.1f}; |
---|
50 | sout | "?/?:" | (v1 / 3); |
---|
51 | |
---|
52 | v1 /= 3; |
---|
53 | sout | "?/=?:" | v1; |
---|
54 | |
---|
55 | v1 = (vec2(float)){2, 3}; |
---|
56 | v2 = (vec2(float)){-3, 2}; |
---|
57 | sout | "dot_1:" | dot(v1, v2); |
---|
58 | |
---|
59 | v2 = (vec2(float)){1.3f, 2}; |
---|
60 | sout | "dot_2:" | dot(v1, v2); |
---|
61 | |
---|
62 | v1 = (vec2(float)){4, 3}; |
---|
63 | sout | "length:" | length(v1); |
---|
64 | |
---|
65 | sout | "length_squared:" | length_squared(v1); |
---|
66 | |
---|
67 | v2 = (vec2(float)){6, -3.2f}; |
---|
68 | sout | "distance:" | distance(v1, v2); |
---|
69 | |
---|
70 | sout | "normalize:" | normalize(v2); |
---|
71 | |
---|
72 | v1 = (vec2(float)){1,0}; |
---|
73 | sout | "normalize_2:" | normalize(v1); |
---|
74 | |
---|
75 | sout | "project:" | project((vec2(float)){5,6}, (vec2(float)){1, 0}); |
---|
76 | sout | "project_2:" | project((vec2(float)){5,6}, (vec2(float)){1, 1}); |
---|
77 | |
---|
78 | v1 = (vec2(float)){5,6}; |
---|
79 | v2 = (vec2(float)){1,0}; |
---|
80 | sout | "reflect:" | reflect(v1,v2); |
---|
81 | |
---|
82 | v2 = (vec2(float)){0,-1}; |
---|
83 | sout | "refract:" | refract(v1,normalize(v2),1); |
---|
84 | sout | "refract:" | refract(v1,normalize(v2),1.f/1.33f); |
---|
85 | |
---|
86 | vec2(float) geometric_normal = {5,6}; |
---|
87 | vec2(float) perturbed_normal = {4,5.5f}; |
---|
88 | vec2(float) eyeline = {-1,0.002f}; |
---|
89 | sout | "faceforward_nochange:" | faceforward(perturbed_normal, eyeline, geometric_normal); |
---|
90 | |
---|
91 | eyeline = (vec2(float)){1,0.002f}; |
---|
92 | sout | "faceforward_flip:" | faceforward(perturbed_normal, eyeline, geometric_normal); |
---|
93 | } |
---|