Mercurial > games > semicongine
annotate old_tests/test_vector.nim @ 1499:1f58458b7ef7 default tip main
did: fix a few issues with tests
| author | sam <sam@basx.dev> | 
|---|---|
| date | Tue, 14 Oct 2025 00:27:28 +0700 | 
| parents | 6360c8d17ce0 | 
| children | 
| rev | line source | 
|---|---|
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
1 import random | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
2 | 
| 212 | 3 import semicongine | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
4 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
5 | 
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
6 proc echoInfo[T](v: TVec2[T] or TVec3[T] or TVec4[T]) = | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
7 echo v | 
| 1136 | 8 echo " Length: ", v.Length | 
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
9 when T is SomeFloat: | 
| 1136 | 10 echo " Normlized: ", v.Normalized | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
11 echo " negated: ", -v | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
12 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
13 proc echoAdd[T, U](v1: T, v2: U) = | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
14 echo v1, " + ", v2, " = ", v1 + v2 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
15 proc echoSub[T, U](v1: T, v2: U) = | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
16 echo v1, " - ", v2, " = ", v1 - v2 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
17 proc echoMul[T, U](v1: T, v2: U) = | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
18 echo v1, " * ", v2, " = ", v1 * v2 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
19 proc echoDiv[T, U](v1: T, v2: U) = | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
20 echo v1, " / ", v2, " = ", v1 / v2 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
21 proc echoDot[T, U](v1: T, v2: U) = | 
| 1136 | 22 echo v1, " o ", v2, " = ", v1.Dot(v2) | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
23 proc echoCross[T, U](v1: T, v2: U) = | 
| 1136 | 24 echo v1, " x ", v2, " = ", v1.Cross(v2) | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
25 | 
| 1136 | 26 proc randVec2I(): auto = NewVec2(rand(1 .. 10), rand(1 .. 10)) | 
| 27 proc randVec2F(): auto = NewVec2(rand(10'f) + 0.01, rand(10'f) + 0.01) | |
| 28 proc randVec3I(): auto = NewVec3(rand(1 .. 10), rand(1 .. 10), rand(1 .. 10)) | |
| 29 proc randVec3F(): auto = NewVec3(rand(10'f) + 0.01, rand(10'f) + 0.01, rand( | |
| 
60
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
30 10'f) + 0.01) | 
| 1136 | 31 proc randVec4I(): auto = NewVec4(rand(1 .. 10), rand(1 .. 10), rand(1 .. 10), | 
| 
60
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
32 rand(1 .. 10)) | 
| 1136 | 33 proc randVec4F(): auto = NewVec4(rand(10'f) + 0.01, rand(10'f) + 0.01, rand( | 
| 
60
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
34 10'f) + 0.01, rand(10'f) + 0.01) | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
35 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
36 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
37 proc testVector() = | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
38 echoInfo(randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
39 echoInfo(randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
40 echoInfo(randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
41 echoInfo(randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
42 echoInfo(randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
43 echoInfo(randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
44 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
45 # test math operations vector-vector | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
46 echoAdd(randVec2I(), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
47 echoAdd(randVec2F(), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
48 echoAdd(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
49 echoAdd(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
50 echoAdd(randVec4I(), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
51 echoAdd(randVec4F(), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
52 echoSub(randVec2I(), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
53 echoSub(randVec2F(), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
54 echoSub(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
55 echoSub(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
56 echoSub(randVec4I(), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
57 echoSub(randVec4F(), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
58 echoMul(randVec2I(), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
59 echoMul(randVec2F(), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
60 echoMul(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
61 echoMul(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
62 echoMul(randVec4I(), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
63 echoMul(randVec4F(), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
64 echoDiv(randVec2I(), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
65 echoDiv(randVec2F(), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
66 echoDiv(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
67 echoDiv(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
68 echoDiv(randVec4I(), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
69 echoDiv(randVec4F(), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
70 echoDot(randVec2I(), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
71 echoDot(randVec2F(), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
72 echoDot(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
73 echoDot(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
74 echoDot(randVec4I(), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
75 echoDot(randVec4F(), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
76 echoCross(randVec3I(), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
77 echoCross(randVec3F(), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
78 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
79 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
80 # test math operations vector-scalar | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
81 echoAdd(randVec2I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
82 echoAdd(randVec2F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
83 echoAdd(randVec3I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
84 echoAdd(randVec3F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
85 echoAdd(randVec4I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
86 echoAdd(randVec4F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
87 echoSub(randVec2I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
88 echoSub(randVec2F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
89 echoSub(randVec3I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
90 echoSub(randVec3F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
91 echoSub(randVec4I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
92 echoSub(randVec4F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
93 echoMul(randVec2I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
94 echoMul(randVec2F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
95 echoMul(randVec3I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
96 echoMul(randVec3F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
97 echoMul(randVec4I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
98 echoMul(randVec4F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
99 echoDiv(randVec2I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
100 echoDiv(randVec2F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
101 echoDiv(randVec3I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
102 echoDiv(randVec3F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
103 echoDiv(randVec4I(), rand(1 .. 10)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
104 echoDiv(randVec4F(), rand(10'f)) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
105 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
106 # test math operations scalar-vector | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
107 echoAdd(rand(1 .. 10), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
108 echoAdd(rand(10'f), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
109 echoAdd(rand(1 .. 10), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
110 echoAdd(rand(10'f), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
111 echoAdd(rand(1 .. 10), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
112 echoAdd(rand(10'f), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
113 echoSub(rand(1 .. 10), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
114 echoSub(rand(10'f), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
115 echoSub(rand(1 .. 10), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
116 echoSub(rand(10'f), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
117 echoSub(rand(1 .. 10), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
118 echoSub(rand(10'f), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
119 echoMul(rand(1 .. 10), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
120 echoMul(rand(10'f), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
121 echoMul(rand(1 .. 10), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
122 echoMul(rand(10'f), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
123 echoMul(rand(1 .. 10), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
124 echoMul(rand(10'f), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
125 echoDiv(rand(1 .. 10), randVec2I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
126 echoDiv(rand(10'f), randVec2F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
127 echoDiv(rand(1 .. 10), randVec3I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
128 echoDiv(rand(10'f), randVec3F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
129 echoDiv(rand(1 .. 10), randVec4I()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
130 echoDiv(rand(10'f), randVec4F()) | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
131 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
132 # test attribute syntax sugar | 
| 1136 | 133 echo "float2int ", To[int](randVec2F()) | 
| 134 echo "int2float ", To[float](randVec2I()) | |
| 135 echo "float2int ", To[int](randVec3F()) | |
| 136 echo "int2float ", To[float](randVec3I()) | |
| 137 echo "float2int ", To[int](randVec3F()) | |
| 138 echo "int2float ", To[float](randVec3I()) | |
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
139 | 
| 
60
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
140 echo "V3I.x: ", randVec3I().x | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
141 echo "V3I.y: ", randVec3I().y | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
142 echo "V3F.z: ", randVec3F().z | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
143 echo "V3I.r: ", randVec3I().r | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
144 echo "V3I.g: ", randVec3I().g | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
145 echo "V3F.b: ", randVec3F().b | 
| 
 
c57285d292b6
did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
 
Sam <sam@basx.dev> 
parents: 
57 
diff
changeset
 | 
146 | 
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
147 # test setters | 
| 1136 | 148 var v1 = randVec2I(); v1.x = 1; v1.y = 2; v1.r = 3; v1.g = 4 | 
| 149 v1.xy = randVec2I(); v1.yx = randVec2I(); v1.rg = randVec2I(); v1.gr = randVec2I() | |
| 150 var v2 = randVec2F(); v2.x = 1.0; v2.y = 2.0; v2.r = 3.0; v2.g = 4.0 | |
| 151 v2.xy = randVec2F(); v2.yx = randVec2F(); v2.rg = randVec2F(); v2.gr = randVec2F() | |
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
152 | 
| 1136 | 153 var v3 = randVec3I(); v3.x = 1; v3.y = 2; v3.z = 3; v3.r = 4; v3.g = 5; v3.b = 6 | 
| 154 v3.xyz = randVec3I(); v3.rgb = randVec3I() | |
| 155 var v4 = randVec3F(); v4.x = 1.0; v4.y = 2.0; v4.z = 3.0; v4.r = 4.0; v4.g = 5.0; v4.b = 6.0 | |
| 156 v4.xyz = randVec3F(); v4.rgb = randVec3F() | |
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
157 | 
| 1136 | 158 var v5 = randVec4I(); v5.x = 1; v5.y = 2; v5.z = 3; v5.w = 4; v5.r = 5; v5.g = 6; v5.b = 7; v5.a = 8 | 
| 159 v5.xyzw = randVec4I(); v5.rgba = randVec4I() | |
| 160 var v6 = randVec4F(); v6.x = 1.0; v6.y = 2.0; v6.z = 3.0; v6.w = 4.0; v6.r = 5.0; v6.g = 6.0; v6.b = 7.0; v6.a = 8.0 | |
| 161 v6.xyzw = randVec4F(); v6.rgba = randVec4F() | |
| 
308
 
c73224f9d38f
add: some API improvments for vector, entity, and some other stuff
 
Sam <sam@basx.dev> 
parents: 
212 
diff
changeset
 | 
162 | 
| 
13
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
163 echo "V2I.xx: ", randVec2I().xx | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
164 echo "V2I.yx: ", randVec2I().xy | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
165 echo "V2F.xx: ", randVec2F().xx | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
166 echo "V2F.yx: ", randVec2F().yx | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
167 echo "V2I.rr: ", randVec2I().rr | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
168 echo "V2I.gr: ", randVec2I().gr | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
169 echo "V2F.rr: ", randVec2F().rr | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
170 echo "V2F.gr: ", randVec2F().gr | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
171 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
172 echo "V3I.yyy: ", randVec3I().yyy | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
173 echo "V3I.yxz: ", randVec3I().xyz | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
174 echo "V3F.yyy: ", randVec3F().yyy | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
175 echo "V3F.yxz: ", randVec3F().yxz | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
176 echo "V3I.ggg: ", randVec3I().ggg | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
177 echo "V3I.grb: ", randVec3I().grb | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
178 echo "V3F.ggg: ", randVec3F().ggg | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
179 echo "V3F.grb: ", randVec3F().grb | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
180 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
181 echo "V4I.zzzz: ", randVec4I().zzzz | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
182 echo "V4I.yxzw: ", randVec4I().xyzw | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
183 echo "V4F.zzzz: ", randVec4F().zzzz | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
184 echo "V4F.yxzw: ", randVec4F().yxzw | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
185 echo "V4I.bbbb: ", randVec4I().bbbb | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
186 echo "V4I.grba: ", randVec4I().grba | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
187 echo "V4F.bbbb: ", randVec4F().bbbb | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
188 echo "V4F.grba: ", randVec4F().grba | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
189 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
190 echo "X: ", X | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
191 echo "Y: ", Y | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
192 echo "Z: ", Z | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
193 echo "X: ", Xi | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
194 echo "Y: ", Yi | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
195 echo "Z: ", Zi | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
196 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
197 | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
198 randomize() | 
| 
 
a571db114152
add: vector/matrix modules, tests, nim config script
 
Sam <sam@basx.dev> 
parents:  
diff
changeset
 | 
199 testVector() | 
