Differences From Artifact [b1e1780492]:
- File tests/OFMatrix4x4Tests.m — part of check-in [e31a31bdcb] at 2023-02-18 12:01:58 on branch trunk — OFMatrix4x4: Transform vectors in 4D space (user: js, size: 2933) [annotate] [blame] [check-ins using]
To Artifact [e27fadae34]:
- File
tests/OFMatrix4x4Tests.m
— part of check-in
[975a812f36]
at
2023-02-19 13:37:44
on branch trunk
— OFMatrix4x4: Use 2D arrays in row-major format
This allows writing matrices more naturally, without having to transpose
them in the source. (user: js, size: 3039) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
- (void)matrix4x4Tests
{
void *pool = objc_autoreleasePoolPush();
OFMatrix4x4 *matrix, *matrix2;
OFVector4D point;
TEST(@"+[identityMatrix]",
| | | | | | | | | | | | | | | | | > | | | < | | | | | | 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 |
- (void)matrix4x4Tests
{
void *pool = objc_autoreleasePoolPush();
OFMatrix4x4 *matrix, *matrix2;
OFVector4D point;
TEST(@"+[identityMatrix]",
memcmp([[OFMatrix4x4 identityMatrix] values], (float [4][4]){
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 1 }
}, 16 * sizeof(float)) == 0)
TEST(@"+[matrixWithValues:]",
(matrix = [OFMatrix4x4 matrixWithValues: (float [4][4]){
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 },
{ 13, 14, 15, 16 }
}]))
TEST(@"-[description]",
[matrix.description isEqual: @"<OFMatrix4x4: {\n"
@"\t1 2 3 4\n"
@"\t5 6 7 8\n"
@"\t9 10 11 12\n"
@"\t13 14 15 16\n"
@"}>"])
TEST(@"-[isEqual:]", [[OFMatrix4x4 identityMatrix] isEqual:
[OFMatrix4x4 matrixWithValues: (float [4][4]){
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 1 }
}]])
TEST(@"-[copy]", (matrix2 = [matrix copy]) && [matrix2 isEqual: matrix])
TEST(@"-[multiplyWithMatrix:] #1",
R([matrix2 multiplyWithMatrix: [OFMatrix4x4 identityMatrix]]) &&
[matrix2 isEqual: matrix])
matrix2 = [OFMatrix4x4 matrixWithValues: (float [4][4]){
{ 100, 200, 300, 400 },
{ 500, 600, 700, 800 },
{ 900, 1000, 1100, 1200 },
{ 1300, 1400, 1500, 1600 }
}];
TEST(@"-[multiplyWithMatrix:] #2",
R([matrix2 multiplyWithMatrix: matrix]) &&
[matrix2 isEqual: [OFMatrix4x4 matrixWithValues: (float [4][4]){
{ 9000, 10000, 11000, 12000 },
{ 20200, 22800, 25400, 28000 },
{ 31400, 35600, 39800, 44000 },
{ 42600, 48400, 54200, 60000 }
}]])
TEST(@"[-translateWithVector:]",
R(matrix2 = [OFMatrix4x4 identityMatrix]) &&
R([matrix2 translateWithVector: OFMakeVector3D(1, 2, 3)]) &&
R(point =
[matrix2 transformedVector: OFMakeVector4D(2, 3, 4, 1)]) &&
|
| ︙ | ︙ |