Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | let m1 = mat4.create([ |
michael@0 | 7 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); |
michael@0 | 8 | |
michael@0 | 9 | let m2 = mat4.create([ |
michael@0 | 10 | 0, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16]); |
michael@0 | 11 | |
michael@0 | 12 | mat4.multiply(m1, m2); |
michael@0 | 13 | ok(isApproxVec(m1, [ |
michael@0 | 14 | 275, 302, 329, 356, 304, 336, 368, 400, |
michael@0 | 15 | 332, 368, 404, 440, 360, 400, 440, 480 |
michael@0 | 16 | ]), "The mat4.multiply() function didn't set the values correctly."); |
michael@0 | 17 | |
michael@0 | 18 | let v1 = mat4.multiplyVec3(m1, [1, 2, 3]); |
michael@0 | 19 | ok(isApproxVec(v1, [2239, 2478, 2717]), |
michael@0 | 20 | "The mat4.multiplyVec3() function didn't set the values correctly."); |
michael@0 | 21 | |
michael@0 | 22 | let v2 = mat4.multiplyVec4(m1, [1, 2, 3, 0]); |
michael@0 | 23 | ok(isApproxVec(v2, [1879, 2078, 2277, 2476]), |
michael@0 | 24 | "The mat4.multiplyVec4() function didn't set the values correctly."); |
michael@0 | 25 | |
michael@0 | 26 | mat4.translate(m1, [1, 2, 3]); |
michael@0 | 27 | ok(isApproxVec(m1, [ |
michael@0 | 28 | 275, 302, 329, 356, 304, 336, 368, 400, |
michael@0 | 29 | 332, 368, 404, 440, 2239, 2478, 2717, 2956 |
michael@0 | 30 | ]), "The mat4.translate() function didn't set the values correctly."); |
michael@0 | 31 | |
michael@0 | 32 | mat4.scale(m1, [1, 2, 3]); |
michael@0 | 33 | ok(isApproxVec(m1, [ |
michael@0 | 34 | 275, 302, 329, 356, 608, 672, 736, 800, |
michael@0 | 35 | 996, 1104, 1212, 1320, 2239, 2478, 2717, 2956 |
michael@0 | 36 | ]), "The mat4.scale() function didn't set the values correctly."); |
michael@0 | 37 | |
michael@0 | 38 | mat4.rotate(m1, 0.5, [1, 1, 1]); |
michael@0 | 39 | ok(isApproxVec(m1, [ |
michael@0 | 40 | 210.6123046875, 230.2483367919922, 249.88438415527344, 269.5204162597656, |
michael@0 | 41 | 809.8145751953125, 896.520751953125, 983.2268676757812, |
michael@0 | 42 | 1069.9329833984375, 858.5731201171875, 951.23095703125, |
michael@0 | 43 | 1043.8887939453125, 1136.5465087890625, 2239, 2478, 2717, 2956 |
michael@0 | 44 | ]), "The mat4.rotate() function didn't set the values correctly."); |
michael@0 | 45 | |
michael@0 | 46 | mat4.rotateX(m1, 0.5); |
michael@0 | 47 | ok(isApproxVec(m1, [ |
michael@0 | 48 | 210.6123046875, 230.2483367919922, 249.88438415527344, 269.5204162597656, |
michael@0 | 49 | 1122.301025390625, 1242.8154296875, 1363.3297119140625, |
michael@0 | 50 | 1483.843994140625, 365.2230224609375, 404.96875, 444.71453857421875, |
michael@0 | 51 | 484.460205078125, 2239, 2478, 2717, 2956 |
michael@0 | 52 | ]), "The mat4.rotateX() function didn't set the values correctly."); |
michael@0 | 53 | |
michael@0 | 54 | mat4.rotateY(m1, 0.5); |
michael@0 | 55 | ok(isApproxVec(m1, [ |
michael@0 | 56 | 9.732441902160645, 7.909564018249512, 6.086670875549316, |
michael@0 | 57 | 4.263822555541992, 1122.301025390625, 1242.8154296875, 1363.3297119140625, |
michael@0 | 58 | 1483.843994140625, 421.48626708984375, 465.78045654296875, |
michael@0 | 59 | 510.0746765136719, 554.3687744140625, 2239, 2478, 2717, 2956 |
michael@0 | 60 | ]), "The mat4.rotateY() function didn't set the values correctly."); |
michael@0 | 61 | |
michael@0 | 62 | mat4.rotateZ(m1, 0.5); |
michael@0 | 63 | ok(isApproxVec(m1, [ |
michael@0 | 64 | 546.6007690429688, 602.7787475585938, 658.9566650390625, 715.1345825195312, |
michael@0 | 65 | 980.245849609375, 1086.881103515625, 1193.5162353515625, |
michael@0 | 66 | 1300.1514892578125, 421.48626708984375, 465.78045654296875, |
michael@0 | 67 | 510.0746765136719, 554.3687744140625, 2239, 2478, 2717, 2956 |
michael@0 | 68 | ]), "The mat4.rotateZ() function didn't set the values correctly."); |
michael@0 | 69 | |
michael@0 | 70 | |
michael@0 | 71 | let m3 = mat4.frustum(0, 100, 200, 0, 0.1, 100); |
michael@0 | 72 | ok(isApproxVec(m3, [ |
michael@0 | 73 | 0.0020000000949949026, 0, 0, 0, 0, -0.0010000000474974513, 0, 0, 1, -1, |
michael@0 | 74 | -1.0020020008087158, -1, 0, 0, -0.20020020008087158, 0 |
michael@0 | 75 | ]), "The mat4.frustum() function didn't compute the values correctly."); |
michael@0 | 76 | |
michael@0 | 77 | let m4 = mat4.perspective(45, 1.6, 0.1, 100); |
michael@0 | 78 | ok(isApproxVec(m4, [1.5088834762573242, 0, 0, 0, 0, 2.4142136573791504, 0, |
michael@0 | 79 | 0, 0, 0, -1.0020020008087158, -1, 0, 0, -0.20020020008087158, 0 |
michael@0 | 80 | ]), "The mat4.frustum() function didn't compute the values correctly."); |
michael@0 | 81 | |
michael@0 | 82 | let m5 = mat4.ortho(0, 100, 200, 0, -1, 1); |
michael@0 | 83 | ok(isApproxVec(m5, [ |
michael@0 | 84 | 0.019999999552965164, 0, 0, 0, 0, -0.009999999776482582, 0, 0, |
michael@0 | 85 | 0, 0, -1, 0, -1, 1, 0, 1 |
michael@0 | 86 | ]), "The mat4.ortho() function didn't compute the values correctly."); |
michael@0 | 87 | |
michael@0 | 88 | let m6 = mat4.lookAt([1, 2, 3], [4, 5, 6], [0, 1, 0]); |
michael@0 | 89 | ok(isApproxVec(m6, [ |
michael@0 | 90 | -0.7071067690849304, -0.40824830532073975, -0.5773502588272095, 0, 0, |
michael@0 | 91 | 0.8164966106414795, -0.5773502588272095, 0, 0.7071067690849304, |
michael@0 | 92 | -0.40824830532073975, -0.5773502588272095, 0, -1.4142135381698608, 0, |
michael@0 | 93 | 3.464101552963257, 1 |
michael@0 | 94 | ]), "The mat4.lookAt() function didn't compute the values correctly."); |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | is(mat4.str([ |
michael@0 | 98 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), |
michael@0 | 99 | "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]", |
michael@0 | 100 | "The mat4.str() function didn't work properly."); |
michael@0 | 101 | } |