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