Repository navigation
Expand file tree
/
Copy pathdump_vmath.txt
More file actions
459 lines (425 loc) · 11.2 KB
/
Copy pathdump_vmath.txt
File metadata and controls
459 lines (425 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
== dump ==
notes: matrices are printed in common column-major order
== matrix basics ==
identity:
[
+001.000 +000.000 +000.000 +000.000
+000.000 +001.000 +000.000 +000.000
+000.000 +000.000 +001.000 +000.000
+000.000 +000.000 +000.000 +001.000
]
matrix_a:
[
+001.000 +005.000 +009.000 +013.000
+002.000 +006.000 +010.000 +014.000
+003.000 +007.000 +011.000 +015.000
+004.000 +008.000 +012.000 +016.000
]
matrix_b:
[
-010.000 +050.000 +090.000 +130.000
-020.000 +060.000 +100.000 +140.000
-030.000 +070.000 +110.000 +150.000
-040.000 +080.000 +120.000 +160.000
]
== matrix multiply ==
matrix_a * matrix_b:
[
-900.000 +2020.000 +3140.000 +4260.000
-1000.000 +2280.000 +3560.000 +4840.000
-1100.000 +2540.000 +3980.000 +5420.000
-1200.000 +2800.000 +4400.000 +6000.000
]
matrix_b * matrix_a:
[
+880.000 +1920.000 +2960.000 +4000.000
+960.000 +2080.000 +3200.000 +4320.000
+1040.000 +2240.000 +3440.000 +4640.000
+1120.000 +2400.000 +3680.000 +4960.000
]
== element access [row, col] ==
transform[0, 0]: +001.000
transform[0, 1]: +002.000
transform[0, 2]: +003.000
transform[0, 3]: +004.000
transform[1, 0]: +005.000
transform[1, 1]: +006.000
transform[1, 2]: +007.000
transform[1, 3]: +008.000
transform[2, 0]: +009.000
transform[2, 1]: +010.000
transform[2, 2]: +011.000
transform[2, 3]: +012.000
transform[3, 0]: +013.000
transform[3, 1]: +014.000
transform[3, 2]: +015.000
transform[3, 3]: +016.000
== mat2 basics ==
identity:
[
+001.000 +000.000
+000.000 +001.000
]
mat2_a:
[
+001.000 +003.000
+002.000 +004.000
]
mat2_b:
[
+005.000 +007.000
-006.000 -008.000
]
== mat2 multiply ==
mat2_a * mat2_b:
[
-013.000 -017.000
-014.000 -018.000
]
mat2_b * mat2_a:
[
+019.000 +043.000
-022.000 -050.000
]
== mat2 element access [row, col] ==
mat2[0, 0]: +001.000
mat2[0, 1]: +002.000
mat2[1, 0]: +003.000
mat2[1, 1]: +004.000
== mat2 vector multiply ==
vec2_input: <+001.250, -002.500>
mat2_a * vec2: <-006.250, -007.500>
== mat2 transpose ==
mat2_a.transpose:
[
+001.000 +002.000
+003.000 +004.000
]
== mat2 inverse ==
mat2_a.inverse:
[
-002.000 +001.500
+001.000 -000.500
]
== mat3 basics ==
identity:
[
+001.000 +000.000 +000.000
+000.000 +001.000 +000.000
+000.000 +000.000 +001.000
]
mat3_a:
[
+001.000 +004.000 +007.000
+002.000 +005.000 +008.000
+003.000 +006.000 +010.000
]
mat3_b:
[
-001.000 +007.000 +006.000
+003.000 -002.000 +008.000
+005.000 +004.000 -003.000
]
== mat3 multiply ==
mat3_a * mat3_b:
[
+046.000 +027.000 +017.000
+053.000 +036.000 +028.000
+065.000 +049.000 +036.000
]
mat3_b * mat3_a:
[
+031.000 +067.000 +109.000
+023.000 +050.000 +085.000
+004.000 +022.000 +037.000
]
== mat3 element access [row, col] ==
mat3[0, 0]: +001.000
mat3[0, 1]: +002.000
mat3[0, 2]: +003.000
mat3[1, 0]: +004.000
mat3[1, 1]: +005.000
mat3[1, 2]: +006.000
mat3[2, 0]: +007.000
mat3[2, 1]: +008.000
mat3[2, 2]: +010.000
== mat3 vector multiply ==
vec2_input: <+003.000, -001.500>
vec3_input: <+001.000, -002.000, +003.000>
mat3_a * vec2: <+004.000, +006.500>
mat3_a * vec3: <+014.000, +016.000, +021.000>
== mat3 transpose ==
mat3_a.transpose:
[
+001.000 +002.000 +003.000
+004.000 +005.000 +006.000
+007.000 +008.000 +010.000
]
== mat3 inverse ==
mat3_a.inverse:
[
-000.667 -000.667 +001.000
-001.333 +003.667 -002.000
+001.000 -002.000 +001.000
]
== mat3 constructors ==
scale2d:
[
+002.000 +000.000 +000.000
+000.000 +003.000 +000.000
+000.000 +000.000 +001.000
]
translate2d:
[
+001.000 +000.000 +005.000
+000.000 +001.000 +010.000
+000.000 +000.000 +001.000
]
rotate_angle_radians: +000.785
rotate2d:
[
+000.707 -000.707 +000.000
+000.707 +000.707 +000.000
+000.000 +000.000 +001.000
]
translate * rotate * scale:
[
+001.414 -002.121 +005.000
+001.414 +002.121 +010.000
+000.000 +000.000 +001.000
]
== matrix constructors and composition ==
scale:
[
+002.000 +000.000 +000.000 +000.000
+000.000 +003.000 +000.000 +000.000
+000.000 +000.000 +004.000 +000.000
+000.000 +000.000 +000.000 +001.000
]
translate:
[
+001.000 +000.000 +000.000 +010.000
+000.000 +001.000 +000.000 +020.000
+000.000 +000.000 +001.000 +030.000
+000.000 +000.000 +000.000 +001.000
]
rotate_x:
[
+001.000 +000.000 +000.000 +000.000
+000.000 +000.799 -000.602 +000.000
+000.000 +000.602 +000.799 +000.000
+000.000 +000.000 +000.000 +001.000
]
rotate_y:
[
+000.921 +000.000 -000.391 +000.000
+000.000 +001.000 +000.000 +000.000
+000.391 +000.000 +000.921 +000.000
+000.000 +000.000 +000.000 +001.000
]
rotate_z:
[
+000.326 -000.946 +000.000 +000.000
+000.946 +000.326 +000.000 +000.000
+000.000 +000.000 +001.000 +000.000
+000.000 +000.000 +000.000 +001.000
]
pure_rotation = rotate_z * rotate_y * rotate_x:
[
+000.300 -000.832 +000.467 +000.000
+000.870 +000.038 -000.491 +000.000
+000.391 +000.554 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
transform = translate * rotate_z * rotate_y * rotate_x * scale:
[
+000.599 -002.495 +001.870 +010.000
+001.741 +000.113 -001.964 +020.000
+000.781 +001.662 +002.941 +030.000
+000.000 +000.000 +000.000 +001.000
]
== matrix vector multiply ==
vec3_input: <+001.250, -002.500, +003.750>
vec4_input: <+001.250, -002.500, +003.750, +001.000>
transform * vec3: <+023.998, +014.529, +037.849>
transform * vec4: <+023.998, +014.529, +037.849, +001.000>
rotate_z * vec3: <+002.771, +000.368, +003.750>
translate * vec3: <+011.250, +017.500, +033.750>
== quaternion constructors ==
quat_identity: <+000.000, +000.000, +000.000, +001.000>
quat_rotate_x: <+000.317, +000.000, +000.000, +000.948>
quat_rotate_y: <+000.000, -000.199, +000.000, +000.980>
quat_rotate_z: <+000.000, +000.000, +000.581, +000.814>
axis_normalized: <+000.267, +000.535, -000.802>
axis_angle_radians: +000.838
from_axis_angle: <+000.109, +000.217, -000.326, +000.914>
from_axis_angle.mat4:
[
+000.693 +000.643 +000.326 +000.000
-000.549 +000.764 -000.340 +000.000
-000.468 +000.057 +000.882 +000.000
+000.000 +000.000 +000.000 +001.000
]
== quaternion multiply ==
quat_x: <+000.317, +000.000, +000.000, +000.948>
quat_y: <+000.000, -000.199, +000.000, +000.980>
quat_z: <+000.000, +000.000, +000.581, +000.814>
quat_multiply(quat_x, quat_y): <+000.311, -000.189, -000.063, +000.929>
quat_multiply(quat_multiply(quat_x, quat_y), quat_z): <+000.143, -000.334, +000.488, +000.793>
quat_xy.mat4:
[
+000.921 +000.000 -000.391 +000.000
-000.235 +000.799 -000.554 +000.000
+000.312 +000.602 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
quat_xyz.mat4:
[
+000.300 -000.870 -000.391 +000.000
+000.679 +000.482 -000.554 +000.000
+000.671 -000.099 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
== quaternion vector rotate ==
input: <+001.250, -002.500, +003.750>
quat_rotate(quat_x, input): <+001.250, -004.253, +001.490>
quat_rotate(quat_y, input): <-000.315, -002.500, +003.940>
quat_rotate(quat_z, input): <+002.771, +000.368, +003.750>
quat_rotate(from_axis_angle, input): <+000.482, -003.871, +002.580>
quat_z * input: <+002.771, +000.368, +003.750>
== matrix quaternion roundtrip ==
pure_rotation.quat: <+000.363, +000.027, +000.591, +000.720>
pure_rotation:
[
+000.300 -000.832 +000.467 +000.000
+000.870 +000.038 -000.491 +000.000
+000.391 +000.554 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
pure_rotation.quat.mat4:
[
+000.300 -000.832 +000.467 +000.000
+000.870 +000.038 -000.491 +000.000
+000.391 +000.554 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
transform.rotation_only:
[
+000.599 -002.495 +001.870 +000.000
+001.741 +000.113 -001.964 +000.000
+000.781 +001.662 +002.941 +000.000
+000.000 +000.000 +000.000 +001.000
]
transform.rotation_only.quat: <+000.840, +000.252, +000.982, +001.079>
axis_mat.quat: <+000.109, +000.217, -000.326, +000.914>
axis_mat.quat.mat4:
[
+000.693 +000.643 +000.326 +000.000
-000.549 +000.764 -000.340 +000.000
-000.468 +000.057 +000.882 +000.000
+000.000 +000.000 +000.000 +001.000
]
hard_decomp.note: 170 degrees around (1,-2,3) normalized - w near zero
hard_decomp.quat_original: <+000.266, -000.532, +000.799, +000.087>
hard_decomp.quat_from_mat: <+000.266, -000.532, +000.799, +000.087>
hard_decomp.mat4:
[
-000.843 -000.423 +000.332 +000.000
-000.144 -000.418 -000.897 +000.000
+000.518 -000.804 +000.291 +000.000
+000.000 +000.000 +000.000 +001.000
]
hard_decomp.quat_from_mat.mat4:
[
-000.843 -000.423 +000.332 +000.000
-000.144 -000.418 -000.897 +000.000
+000.518 -000.804 +000.291 +000.000
+000.000 +000.000 +000.000 +001.000
]
== lookAt matrix ==
notes: eye=(5,5,5), center=(0,0,0), up=(0,1,0)
lookAt:
[
+000.707 +000.000 -000.707 +000.000
-000.408 +000.816 -000.408 +000.000
+000.577 +000.577 +000.577 -008.660
+000.000 +000.000 +000.000 +001.000
]
== euler angle decomposition ==
notes: euler angles as vec3(pitch/x, yaw/y, roll/z) in radians
pure_rotation.quat.euler: <+000.646, -000.401, +001.239>
from_axis_angle.euler: <+000.064, +000.487, -000.670>
== matrix inverse ==
transform.inverse:
[
+000.150 +000.435 +000.195 -016.063
-000.277 +000.013 +000.185 -003.019
+000.117 -000.123 +000.184 -004.227
+000.000 +000.000 +000.000 +001.000
]
pure_rotation.inverse:
[
+000.300 +000.870 +000.391 +000.000
-000.832 +000.038 +000.554 +000.000
+000.467 -000.491 +000.735 +000.000
+000.000 +000.000 +000.000 +001.000
]
== cross product ==
notes: cross(a, b) where a and b are vec3
cross(x_axis, y_axis): <+000.000, +000.000, +001.000>
cross(y_axis, x_axis): <+000.000, +000.000, -001.000>
cross(c, d): <+000.292, -000.583, +000.292>
== slerp ==
notes: slerp(a, b, t) between quat_x and quat_z
slerp(quat_x, quat_z, 0.25): <+000.247, +000.000, +000.157, +000.956>
slerp(quat_x, quat_z, 0.5): <+000.169, +000.000, +000.308, +000.936>
slerp(quat_x, quat_z, 0.75): <+000.086, +000.000, +000.451, +000.888>
== fromTwoVectors ==
notes: quaternion that rotates vector a to vector b
from_x_to_y: <+000.000, +000.000, +000.707, +000.707>
from_c_to_d: <+000.707, -000.157, +000.393, +000.567>
verify_x_to_y: <+000.000, +001.000, +000.000>
verify_c_to_d: <-000.436, +000.218, +000.873>
== quaternion inverse ==
from_axis_angle.inverse: <-000.109, -000.217, +000.326, +000.914>
verify_q_mul_qinv: <+000.000, +000.000, +000.000, +001.000>
== quaternion to axis-angle ==
from_axis_angle.axis: <+000.267, +000.535, -000.802>
from_axis_angle.angle: +000.838
quat_xyz.axis: <+000.235, -000.549, +000.802>
quat_xyz.angle: +001.309
== perspective matrix ==
notes: fovy=60 degrees, aspect=1.5, near=0.1, far=100.0
perspective:
[
+001.155 +000.000 +000.000 +000.000
+000.000 +001.732 +000.000 +000.000
+000.000 +000.000 -001.002 -000.200
+000.000 +000.000 -001.000 +000.000
]
== ortho matrix ==
notes: left=-10, right=10, bottom=-7.5, top=7.5, near=0.1, far=100.0
ortho:
[
+000.100 +000.000 +000.000 +000.000
+000.000 +000.133 +000.000 +000.000
+000.000 +000.000 -000.020 -001.002
+000.000 +000.000 +000.000 +001.000
]
== basis directions ==
forward: <+009.000, +010.000, +011.000>
right: <+001.000, +002.000, +003.000>
up: <+005.000, +006.000, +007.000>
== default matrix printer ==
matrix_a.default: mat4(
1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0
)
transform.default: mat4(
0.5993741, 1.7407088, 0.78146225, 0.0,
-2.4950442, 0.11302096, 1.6619208, 0.0,
1.8697325, -1.9639301, 2.9405916, 0.0,
10.0, 20.0, 30.0, 1.0
)