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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
|
#include "skin_matrix.h"
#include "gfx.h"
#include "printf.h"
#include "terminal.h"
#include "translation.h"
#include "z_lib.h"
// clang-format off
MtxF sMtxFClear = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
};
// clang-format on
/**
* Multiplies the matrix mf by a 4 components column vector [ src , 1 ] and writes the resulting 4 components to xyzDest
* and wDest.
*
* \f[ \begin{bmatrix} \texttt{xyzDest} \\ \texttt{wDest} \\ \end{bmatrix}
* = [\texttt{mf}] \cdot
* \begin{bmatrix} \texttt{src} \\ 1 \\ \end{bmatrix}
* \f]
*/
void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) {
xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz));
xyzDest->y = mf->yw + ((src->x * mf->yx) + (src->y * mf->yy) + (src->z * mf->yz));
xyzDest->z = mf->zw + ((src->x * mf->zx) + (src->y * mf->zy) + (src->z * mf->zz));
*wDest = mf->ww + ((src->x * mf->wx) + (src->y * mf->wy) + (src->z * mf->wz));
}
/**
* Multiplies the matrix mf by a 4 components column vector [ src , 1 ] and writes the resulting xyz components to dest.
*
* \f[ \begin{bmatrix} \texttt{dest} \\ - \\ \end{bmatrix}
* = [\texttt{mf}] \cdot
* \begin{bmatrix} \texttt{src} \\ 1 \\ \end{bmatrix}
* \f]
*/
void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) {
f32 mx = mf->xx;
f32 my = mf->xy;
f32 mz = mf->xz;
f32 mw = mf->xw;
dest->x = mw + ((src->x * mx) + (src->y * my) + (src->z * mz));
mx = mf->yx;
my = mf->yy;
mz = mf->yz;
mw = mf->yw;
dest->y = mw + ((src->x * mx) + (src->y * my) + (src->z * mz));
mx = mf->zx;
my = mf->zy;
mz = mf->zz;
mw = mf->zw;
dest->z = mw + ((src->x * mx) + (src->y * my) + (src->z * mz));
}
/**
* Matrix multiplication, dest = mfA * mfB.
* mfB and dest should not be the same matrix.
*/
void SkinMatrix_MtxFMtxFMult(MtxF* mfA, MtxF* mfB, MtxF* dest) {
f32 cx;
f32 cy;
f32 cz;
f32 cw;
//---ROW1---
f32 rx = mfA->xx;
f32 ry = mfA->xy;
f32 rz = mfA->xz;
f32 rw = mfA->xw;
//--------
cx = mfB->xx;
cy = mfB->yx;
cz = mfB->zx;
cw = mfB->wx;
dest->xx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xy;
cy = mfB->yy;
cz = mfB->zy;
cw = mfB->wy;
dest->xy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xz;
cy = mfB->yz;
cz = mfB->zz;
cw = mfB->wz;
dest->xz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xw;
cy = mfB->yw;
cz = mfB->zw;
cw = mfB->ww;
dest->xw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
//---ROW2---
rx = mfA->yx;
ry = mfA->yy;
rz = mfA->yz;
rw = mfA->yw;
//--------
cx = mfB->xx;
cy = mfB->yx;
cz = mfB->zx;
cw = mfB->wx;
dest->yx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xy;
cy = mfB->yy;
cz = mfB->zy;
cw = mfB->wy;
dest->yy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xz;
cy = mfB->yz;
cz = mfB->zz;
cw = mfB->wz;
dest->yz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xw;
cy = mfB->yw;
cz = mfB->zw;
cw = mfB->ww;
dest->yw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
//---ROW3---
rx = mfA->zx;
ry = mfA->zy;
rz = mfA->zz;
rw = mfA->zw;
//--------
cx = mfB->xx;
cy = mfB->yx;
cz = mfB->zx;
cw = mfB->wx;
dest->zx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xy;
cy = mfB->yy;
cz = mfB->zy;
cw = mfB->wy;
dest->zy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xz;
cy = mfB->yz;
cz = mfB->zz;
cw = mfB->wz;
dest->zz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xw;
cy = mfB->yw;
cz = mfB->zw;
cw = mfB->ww;
dest->zw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
//---ROW4---
rx = mfA->wx;
ry = mfA->wy;
rz = mfA->wz;
rw = mfA->ww;
//--------
cx = mfB->xx;
cy = mfB->yx;
cz = mfB->zx;
cw = mfB->wx;
dest->wx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xy;
cy = mfB->yy;
cz = mfB->zy;
cw = mfB->wy;
dest->wy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xz;
cy = mfB->yz;
cz = mfB->zz;
cw = mfB->wz;
dest->wz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
cx = mfB->xw;
cy = mfB->yw;
cz = mfB->zw;
cw = mfB->ww;
dest->ww = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
}
/**
* "Clear" in this file means the identity matrix.
*/
void SkinMatrix_GetClear(MtxF** mfp) {
*mfp = &sMtxFClear;
}
void SkinMatrix_Clear(MtxF* mf) {
mf->xx = 1.0f;
mf->yx = 0.0f;
mf->zx = 0.0f;
mf->wx = 0.0f;
mf->xy = 0.0f;
mf->yy = 1.0f;
mf->zy = 0.0f;
mf->wy = 0.0f;
mf->xz = 0.0f;
mf->yz = 0.0f;
mf->zz = 1.0f;
mf->wz = 0.0f;
mf->xw = 0.0f;
mf->yw = 0.0f;
mf->zw = 0.0f;
mf->ww = 1.0f;
}
void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) {
dest->xx = src->xx;
dest->yx = src->yx;
dest->zx = src->zx;
dest->wx = src->wx;
dest->xy = src->xy;
dest->yy = src->yy;
dest->zy = src->zy;
dest->wy = src->wy;
dest->xz = src->xz;
dest->yz = src->yz;
dest->zz = src->zz;
dest->wz = src->wz;
dest->xw = src->xw;
dest->yw = src->yw;
dest->zw = src->zw;
dest->ww = src->ww;
}
/**
* Inverts a matrix using the Gauss-Jordan method.
* returns 0 if successfully inverted
* returns 2 if matrix non-invertible (0 determinant)
*/
s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) {
MtxF mfCopy;
s32 i;
f32 temp1;
s32 thisCol;
s32 thisRow;
SkinMatrix_MtxFCopy(src, &mfCopy);
SkinMatrix_Clear(dest);
for (thisCol = 0; thisCol < 4; thisCol++) {
thisRow = thisCol;
while ((thisRow < 4) && (fabsf(mfCopy.mf[thisCol][thisRow]) < 0.0005f)) {
thisRow++;
}
if (thisRow == 4) {
// Reaching row = 4 means the column is either all 0 or a duplicate column.
// Therefore src is a singular matrix (0 determinant).
PRINTF_COLOR_WARNING();
PRINTF(T("Skin_Matrix_InverseMatrix():逆行列つくれません\n",
"Skin_Matrix_InverseMatrix(): Cannot create inverse matrix\n"));
PRINTF_RST();
return 2;
}
if (thisRow != thisCol) {
// Diagonal element mf[thisCol][thisCol] is zero.
// Swap the rows thisCol and thisRow.
for (i = 0; i < 4; i++) {
SWAP(f32, mfCopy.mf[i][thisRow], mfCopy.mf[i][thisCol]);
SWAP(f32, dest->mf[i][thisRow], dest->mf[i][thisCol]);
}
}
// Scale this whole row such that the diagonal element is 1.
temp1 = mfCopy.mf[thisCol][thisCol];
for (i = 0; i < 4; i++) {
mfCopy.mf[i][thisCol] /= temp1;
dest->mf[i][thisCol] /= temp1;
}
for (thisRow = 0; thisRow < 4; thisRow++) {
if (thisRow != thisCol) {
temp1 = mfCopy.mf[thisCol][thisRow];
for (i = 0; i < 4; i++) {
mfCopy.mf[i][thisRow] -= mfCopy.mf[i][thisCol] * temp1;
dest->mf[i][thisRow] -= dest->mf[i][thisCol] * temp1;
}
}
}
}
return 0;
}
/**
* Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS)
*/
void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) {
mf->yx = 0.0f;
mf->zx = 0.0f;
mf->wx = 0.0f;
mf->xy = 0.0f;
mf->zy = 0.0f;
mf->wy = 0.0f;
mf->xz = 0.0f;
mf->yz = 0.0f;
mf->wz = 0.0f;
mf->xw = 0.0f;
mf->yw = 0.0f;
mf->zw = 0.0f;
mf->ww = 1.0f;
mf->xx = x;
mf->yy = y;
mf->zz = z;
}
/**
* Produces a rotation matrix using ZYX Tait-Bryan angles.
*/
void SkinMatrix_SetRotateZYX(MtxF* mf, s16 x, s16 y, s16 z) {
f32 cos;
f32 sinZ = Math_SinS(z);
f32 cosZ = Math_CosS(z);
f32 xy;
f32 sin;
f32 xz;
f32 yy;
f32 yz;
mf->yy = cosZ;
mf->xy = -sinZ;
mf->wx = mf->wy = mf->wz = 0;
mf->xw = mf->yw = mf->zw = 0;
mf->ww = 1;
if (y != 0) {
sin = Math_SinS(y);
cos = Math_CosS(y);
mf->xx = cosZ * cos;
mf->xz = cosZ * sin;
mf->yx = sinZ * cos;
mf->yz = sinZ * sin;
mf->zx = -sin;
mf->zz = cos;
} else {
mf->xx = cosZ;
if (1) {}
if (1) {}
xz = sinZ; // required to match
mf->yx = sinZ;
mf->zx = mf->xz = mf->yz = 0;
mf->zz = 1;
}
if (x != 0) {
sin = Math_SinS(x);
cos = Math_CosS(x);
xy = mf->xy;
xz = mf->xz;
mf->xy = (xy * cos) + (xz * sin);
mf->xz = (xz * cos) - (xy * sin);
if (1) {}
yz = mf->yz;
yy = mf->yy;
mf->yy = (yy * cos) + (yz * sin);
mf->yz = (yz * cos) - (yy * sin);
if (cos) {}
mf->zy = mf->zz * sin;
mf->zz = mf->zz * cos;
} else {
mf->zy = 0;
}
}
/**
* Produces a rotation matrix using YXZ Tait-Bryan angles.
*/
void SkinMatrix_SetRotateYXZ(MtxF* mf, s16 x, s16 y, s16 z) {
f32 cos;
f32 sinY = Math_SinS(y);
f32 cosY = Math_CosS(y);
f32 zx;
f32 sin;
f32 zy;
f32 xx;
f32 xy;
mf->xx = cosY;
mf->zx = -sinY;
mf->wz = 0;
mf->wy = 0;
mf->wx = 0;
mf->zw = 0;
mf->yw = 0;
mf->xw = 0;
mf->ww = 1;
if (x != 0) {
sin = Math_SinS(x);
cos = Math_CosS(x);
mf->zz = cosY * cos;
mf->zy = cosY * sin;
mf->xz = sinY * cos;
mf->xy = sinY * sin;
mf->yz = -sin;
mf->yy = cos;
} else {
mf->zz = cosY;
if (1) {}
if (1) {}
xy = sinY; // required to match
mf->xz = sinY;
mf->xy = mf->zy = mf->yz = 0;
mf->yy = 1;
}
if (z != 0) {
sin = Math_SinS(z);
cos = Math_CosS(z);
xx = mf->xx;
xy = mf->xy;
mf->xx = (xx * cos) + (xy * sin);
mf->xy = xy * cos - (xx * sin);
if (1) {}
zy = mf->zy;
zx = mf->zx;
mf->zx = (zx * cos) + (zy * sin);
mf->zy = (zy * cos) - (zx * sin);
if (cos) {}
mf->yx = mf->yy * sin;
mf->yy = mf->yy * cos;
} else {
mf->yx = 0;
}
}
/**
* Produces a matrix which translates a vector by amounts in the x, y and z directions
*/
void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) {
mf->yx = 0.0f;
mf->zx = 0.0f;
mf->wx = 0.0f;
mf->xy = 0.0f;
mf->zy = 0.0f;
mf->wy = 0.0f;
mf->xz = 0.0f;
mf->yz = 0.0f;
mf->wz = 0.0f;
mf->xx = 1.0f;
mf->yy = 1.0f;
mf->zz = 1.0f;
mf->ww = 1.0f;
mf->xw = x;
mf->yw = y;
mf->zw = z;
}
/**
* Produces a matrix which scales, then rotates (using ZYX Tait-Bryan angles), then translates.
*/
void SkinMatrix_SetTranslateRotateZYXScale(MtxF* dest, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ,
f32 translateX, f32 translateY, f32 translateZ) {
MtxF mft1;
MtxF mft2;
SkinMatrix_SetTranslate(dest, translateX, translateY, translateZ);
SkinMatrix_SetRotateZYX(&mft1, rotX, rotY, rotZ);
SkinMatrix_MtxFMtxFMult(dest, &mft1, &mft2);
SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ);
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, dest);
}
/**
* Produces a matrix which scales, then rotates (using YXZ Tait-Bryan angles), then translates.
*/
void SkinMatrix_SetTranslateRotateYXZScale(MtxF* dest, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ,
f32 translateX, f32 translateY, f32 translateZ) {
MtxF mft1;
MtxF mft2;
SkinMatrix_SetTranslate(dest, translateX, translateY, translateZ);
SkinMatrix_SetRotateYXZ(&mft1, rotX, rotY, rotZ);
SkinMatrix_MtxFMtxFMult(dest, &mft1, &mft2);
SkinMatrix_SetScale(&mft1, scaleX, scaleY, scaleZ);
SkinMatrix_MtxFMtxFMult(&mft2, &mft1, dest);
}
/**
* Produces a matrix which rotates (using ZYX Tait-Bryan angles), then translates.
*/
void SkinMatrix_SetTranslateRotateZYX(MtxF* dest, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY,
f32 translateZ) {
MtxF rotation;
MtxF translation;
SkinMatrix_SetTranslate(&translation, translateX, translateY, translateZ);
SkinMatrix_SetRotateZYX(&rotation, rotX, rotY, rotZ);
SkinMatrix_MtxFMtxFMult(&translation, &rotation, dest);
}
void SkinMatrix_Vec3fToVec3s(Vec3f* src, Vec3s* dest) {
dest->x = src->x;
dest->y = src->y;
dest->z = src->z;
}
void SkinMatrix_Vec3sToVec3f(Vec3s* src, Vec3f* dest) {
dest->x = src->x;
dest->y = src->y;
dest->z = src->z;
}
void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) {
s32 temp;
u16* m1 = (u16*)&dest->m[0][0];
u16* m2 = (u16*)&dest->m[2][0];
temp = src->xx * 0x10000;
m1[0] = (temp >> 0x10);
m1[16 + 0] = temp & 0xFFFF;
temp = src->yx * 0x10000;
m1[1] = (temp >> 0x10);
m1[16 + 1] = temp & 0xFFFF;
temp = src->zx * 0x10000;
m1[2] = (temp >> 0x10);
m1[16 + 2] = temp & 0xFFFF;
temp = src->wx * 0x10000;
m1[3] = (temp >> 0x10);
m1[16 + 3] = temp & 0xFFFF;
temp = src->xy * 0x10000;
m1[4] = (temp >> 0x10);
m1[16 + 4] = temp & 0xFFFF;
temp = src->yy * 0x10000;
m1[5] = (temp >> 0x10);
m1[16 + 5] = temp & 0xFFFF;
temp = src->zy * 0x10000;
m1[6] = (temp >> 0x10);
m1[16 + 6] = temp & 0xFFFF;
temp = src->wy * 0x10000;
m1[7] = (temp >> 0x10);
m1[16 + 7] = temp & 0xFFFF;
temp = src->xz * 0x10000;
m1[8] = (temp >> 0x10);
m1[16 + 8] = temp & 0xFFFF;
temp = src->yz * 0x10000;
m1[9] = (temp >> 0x10);
m2[9] = temp & 0xFFFF;
temp = src->zz * 0x10000;
m1[10] = (temp >> 0x10);
m2[10] = temp & 0xFFFF;
temp = src->wz * 0x10000;
m1[11] = (temp >> 0x10);
m2[11] = temp & 0xFFFF;
temp = src->xw * 0x10000;
m1[12] = (temp >> 0x10);
m2[12] = temp & 0xFFFF;
temp = src->yw * 0x10000;
m1[13] = (temp >> 0x10);
m2[13] = temp & 0xFFFF;
temp = src->zw * 0x10000;
m1[14] = (temp >> 0x10);
m2[14] = temp & 0xFFFF;
temp = src->ww * 0x10000;
m1[15] = (temp >> 0x10);
m2[15] = temp & 0xFFFF;
}
Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) {
Mtx* mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx));
if (mtx == NULL) {
PRINTF(T("Skin_Matrix_to_Mtx_new() 確保失敗:NULLを返して終了\n",
"Skin_Matrix_to_Mtx_new() allocation failed: Return NULL and exit\n"));
return NULL;
}
SkinMatrix_MtxFToMtx(src, mtx);
return mtx;
}
/**
* Produces a matrix which rotates by binary angle `angle` around a unit vector (`axisX`,`axisY`,`axisZ`).
* NB: the rotation axis is assumed to be a unit vector.
*/
void SkinMatrix_SetRotateAxis(MtxF* mf, s16 angle, f32 axisX, f32 axisY, f32 axisZ) {
f32 sinA;
f32 cosA;
f32 xx;
f32 yy;
f32 zz;
f32 xy;
f32 yz;
f32 xz;
f32 pad;
sinA = Math_SinS(angle);
cosA = Math_CosS(angle);
xx = axisX * axisX;
yy = axisY * axisY;
zz = axisZ * axisZ;
xy = axisX * axisY;
yz = axisY * axisZ;
xz = axisX * axisZ;
mf->xx = (1.0f - xx) * cosA + xx;
mf->yx = (1.0f - cosA) * xy + axisZ * sinA;
mf->zx = (1.0f - cosA) * xz - axisY * sinA;
mf->wx = 0.0f;
mf->xy = (1.0f - cosA) * xy - axisZ * sinA;
mf->yy = (1.0f - yy) * cosA + yy;
mf->zy = (1.0f - cosA) * yz + axisX * sinA;
mf->wy = 0.0f;
mf->xz = (1.0f - cosA) * xz + axisY * sinA;
mf->yz = (1.0f - cosA) * yz - axisX * sinA;
mf->zz = (1.0f - zz) * cosA + zz;
mf->wz = 0.0f;
mf->xw = mf->yw = mf->zw = 0.0f;
mf->ww = 1.0f;
}
void func_800A8030(MtxF* mf, f32* arg1) {
f32 n;
f32 xNorm;
f32 yNorm;
f32 zNorm;
f32 wxNorm;
f32 wyNorm;
f32 wzNorm;
f32 xxNorm;
f32 xyNorm;
f32 xzNorm;
f32 yyNorm;
f32 yzNorm;
f32 zzNorm;
n = 2.0f / ((arg1[3] * arg1[3]) + ((arg1[2] * arg1[2]) + ((arg1[1] * arg1[1]) + (arg1[0] * arg1[0]))));
xNorm = arg1[0] * n;
yNorm = arg1[1] * n;
zNorm = arg1[2] * n;
wxNorm = arg1[3] * xNorm;
wyNorm = arg1[3] * yNorm;
wzNorm = arg1[3] * zNorm;
xxNorm = arg1[0] * xNorm;
xyNorm = arg1[0] * yNorm;
xzNorm = arg1[0] * zNorm;
yyNorm = arg1[1] * yNorm;
yzNorm = arg1[1] * zNorm;
zzNorm = arg1[2] * zNorm;
mf->xx = (1.0f - (yyNorm + zzNorm));
mf->yx = (xyNorm + wzNorm);
mf->zx = (xzNorm - wyNorm);
mf->wx = 0.0f;
mf->xy = (xyNorm - wzNorm);
mf->yy = (1.0f - (xxNorm + zzNorm));
mf->zy = (yzNorm + wxNorm);
mf->wy = 0.0f;
mf->xz = (yzNorm + wyNorm);
mf->yz = (yzNorm - wxNorm);
mf->zz = (1.0f - (xxNorm + yyNorm));
mf->wz = 0.0f;
mf->xw = 0.0f;
mf->yw = 0.0f;
mf->ww = 1.0f;
mf->zw = 0.0f;
}
|