1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
21 *************************************************************************/
22 //234567890123456789012345678901234567890123456789012345678901234567890123456789
25 #include <UnitTest++.h>
27 #include <ode/odemath.h>
31 TEST(test_dNormalization3
)
33 const dVector3 x
= {1,0,0,0};
34 const dVector3 y
= {0,1,0,0};
35 const dVector3 z
= {0,0,1,0};
38 // Check when value in first component (i.e. [0])
43 CHECK_ARRAY_CLOSE(x
, v
, 3, 1e-6);
44 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
50 CHECK_ARRAY_CLOSE(x
, v
, 3, 1e-6);
51 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
57 CHECK_ARRAY_CLOSE(x
, v
, 3, 1e-6);
58 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
61 // Check when value in first component (i.e. [0])
66 CHECK_ARRAY_CLOSE(y
, v
, 3, 1e-6);
67 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
73 CHECK_ARRAY_CLOSE(y
, v
, 3, 1e-6);
74 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
80 CHECK_ARRAY_CLOSE(y
, v
, 3, 1e-6);
81 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
84 // Check when value in first component (i.e. [0])
89 CHECK_ARRAY_CLOSE(z
, v
, 3, 1e-6);
90 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
96 CHECK_ARRAY_CLOSE(z
, v
, 3, 1e-6);
97 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
103 CHECK_ARRAY_CLOSE(z
, v
, 3, 1e-6);
104 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
108 // Check when value in first component (i.e. [0])
113 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
119 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
125 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
128 // Check when value in first component (i.e. [0])
133 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
139 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
145 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
148 // Check when value in first component (i.e. [0])
153 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
159 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
165 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
168 v
[0] = REAL(9999999999.0);
172 CHECK_EQUAL(dCalcVectorLength3(v
), REAL(1.0));
175 v
[0] = REAL(9999999999.0);
179 CHECK_CLOSE(dCalcVectorLength3(v
), REAL(1.0),REAL(0.001));
184 TEST(test_dOrthogonalizeR
)
187 dMatrix3 r1
= { 1, 0, 0, 0,
192 memcpy(r2
, r1
, sizeof(dMatrix3
));
194 CHECK_ARRAY_EQUAL(r1
, r2
, 12);
197 dMatrix3 r1
= { 0, 1, 0, 0,
202 memcpy(r2
, r1
, sizeof(dMatrix3
));
204 CHECK_ARRAY_EQUAL(r1
, r2
, 12);
207 dMatrix3 r1
= { 0, 0, 1, 0,
212 memcpy(r2
, r1
, sizeof(dMatrix3
));
214 CHECK_ARRAY_EQUAL(r1
, r2
, 12);
217 dMatrix3 r1
= { -1, 0, 0, 0,
222 memcpy(r2
, r1
, sizeof(dMatrix3
));
224 CHECK_ARRAY_EQUAL(r1
, r2
, 12);
227 dMatrix3 r1
= { 0, -1, 0, 0,
232 memcpy(r2
, r1
, sizeof(dMatrix3
));
234 CHECK_ARRAY_EQUAL(r1
, r2
, 12);
237 dMatrix3 r1
= { 0, 0, -1, 0,
242 memcpy(r2
, r1
, sizeof(dMatrix3
));
244 CHECK_ARRAY_EQUAL(r1
, r2
, 12);