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