1 module doml.tests.axis_angle_test; 2 3 4 import std.stdio; 5 import doml.tests.dunit_tests; 6 7 import doml.axis_angle_4d; 8 import doml.quaternion_d; 9 10 import Math = doml.math; 11 12 13 /* 14 * The MIT License 15 * 16 * Copyright (c) 2015-2022 JOML. 17 @#$@# Translated by jordan4ibanez 18 * 19 * Permission is hereby granted, free of charge, to any person obtaining a copy 20 * of this software and associated documentation files (the "Software"), to deal 21 * in the Software without restriction, including without limitation the rights 22 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 * copies of the Software, and to permit persons to whom the Software is 24 * furnished to do so, subject to the following conditions: 25 * 26 * The above copyright notice and this permission notice shall be included in 27 * all copies or substantial portions of the Software. 28 * 29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 * THE SOFTWARE. 36 */ 37 38 unittest { 39 40 writeln("\nBEGIN AXIS ANGLE\n"); 41 42 43 writeln("TESTING ANGLE IDENTITY QUATERNION"); 44 45 AxisAngle4d a = AxisAngle4d().set(Quaterniond()); 46 assertEquals(AxisAngle4d(0, 0, 0, 1), a); 47 a = AxisAngle4d().set(Quaterniond(2.035E-9,4.715E-10,-9.166E-11,1.000E+0)); 48 assertEquals(AxisAngle4d(0, 0, 0, 1), a); 49 50 writeln("PASSED!"); 51 writeln("TESTING ANGLE NORMALIZATION"); 52 53 AxisAngle4d a1 = AxisAngle4d(Math.toRadians(20), 1.0, 0.0, 0.0); 54 AxisAngle4d a2 = AxisAngle4d(Math.toRadians(380), 1.0, 0.0, 0.0); 55 assertEquals(a1.angle, a2.angle, 100_000); // 0.00001 (1E-5f) 56 57 a1 = AxisAngle4d( Math.toRadians(-20), 1.0, 0.0, 0.0); 58 a2 = AxisAngle4d( Math.toRadians(-380.0), 1.0, 0.0, 0.0); 59 assertEquals(a1.angle, a2.angle, 100_000); // 0.00001 (1E-5f) 60 61 a1 = AxisAngle4d( Math.toRadians(-20.0) * 10.0, 1.0, 0.0, 0.0); 62 a2 = AxisAngle4d( Math.toRadians(-380.0) * 10.0, 1.0, 0.0, 0.0); 63 64 assertEquals(a1.angle, a2.angle, 100_000); // 0.00001 (1E-5f) 65 writeln("PASSED!"); 66 }