Changeset 2935
 Timestamp:
 Sep 15, 2013, 6:19:36 PM (6 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/math/vector.cpp
r2929 r2935 632 632 else 633 633 { 634 vec4 v1(c0 * c1 * c2, s0 * c1 * c2, c0 * s1 * c2, c0 * c1 * s2); 635 vec4 v2(s0 * s1 * s2, c0 * s1 * s2, s0 * c1 * s2, s0 * s1 * c2); 636 637 ret[0] = v1[0] + sign * v2[0]; 638 ret[1 + i] = v1[1] + sign * v2[1]; 639 ret[1 + j] = v1[2] + sign * v2[2]; 640 ret[1 + k] = v1[3] + sign * v2[3]; 634 ret[0] = c0 * c1 * c2  sign * (s0 * s1 * s2); 635 ret[1 + i] = s0 * c1 * c2 + sign * (c0 * s1 * s2); 636 ret[1 + j] = c0 * s1 * c2  sign * (s0 * c1 * s2); 637 ret[1 + k] = c0 * c1 * s2 + sign * (s0 * s1 * c2); 641 638 } 642 639 
trunk/test/unit/quat.cpp
r2862 r2935 189 189 LOLUNIT_ASSERT_DOUBLES_EQUAL(d.z, a.z / ratio, 1e5); 190 190 } 191 192 LOLUNIT_TEST(TaitBryanAngles) 193 { 194 for (int i = 0; i < 10; ++i) 195 { 196 /* Pick a random point and a random quaternion. We’re going 197 * to check whether going to TaitBryan angles and back to 198 * quaternion creates the same transform. */ 199 vec3 p(rand(1.f, 2.f), rand(1.f, 2.f), rand(1.f, 2.f)); 200 quat q = normalize(quat(rand(1.f, 1.f), rand(1.f, 1.f), 201 rand(1.f, 1.f), rand(1.f, 1.f))); 202 vec3 p0 = q.transform(p); 203 204 /* xyz */ 205 quat q1 = quat::fromeuler_xyz(vec3::toeuler_xyz(q)); 206 vec3 p1 = q1.transform(p); 207 208 LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e4); 209 LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e4); 210 LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e4); 211 212 /* yzx */ 213 quat q2 = quat::fromeuler_yzx(vec3::toeuler_yzx(q)); 214 vec3 p2 = q2.transform(p); 215 216 LOLUNIT_ASSERT_DOUBLES_EQUAL(p2.x, p0.x, 1e4); 217 LOLUNIT_ASSERT_DOUBLES_EQUAL(p2.y, p0.y, 1e4); 218 LOLUNIT_ASSERT_DOUBLES_EQUAL(p2.z, p0.z, 1e4); 219 220 /* zxy */ 221 quat q3 = quat::fromeuler_zxy(vec3::toeuler_zxy(q)); 222 vec3 p3 = q3.transform(p); 223 224 LOLUNIT_ASSERT_DOUBLES_EQUAL(p3.x, p0.x, 1e4); 225 LOLUNIT_ASSERT_DOUBLES_EQUAL(p3.y, p0.y, 1e4); 226 LOLUNIT_ASSERT_DOUBLES_EQUAL(p3.z, p0.z, 1e4); 227 228 /* xzy */ 229 quat q4 = quat::fromeuler_xzy(vec3::toeuler_xzy(q)); 230 vec3 p4 = q4.transform(p); 231 232 LOLUNIT_ASSERT_DOUBLES_EQUAL(p4.x, p0.x, 1e4); 233 LOLUNIT_ASSERT_DOUBLES_EQUAL(p4.y, p0.y, 1e4); 234 LOLUNIT_ASSERT_DOUBLES_EQUAL(p4.z, p0.z, 1e4); 235 236 /* zyx */ 237 quat q5 = quat::fromeuler_zyx(vec3::toeuler_zyx(q)); 238 vec3 p5 = q5.transform(p); 239 240 LOLUNIT_ASSERT_DOUBLES_EQUAL(p5.x, p0.x, 1e4); 241 LOLUNIT_ASSERT_DOUBLES_EQUAL(p5.y, p0.y, 1e4); 242 LOLUNIT_ASSERT_DOUBLES_EQUAL(p5.z, p0.z, 1e4); 243 244 /* yxz */ 245 quat q6 = quat::fromeuler_yxz(vec3::toeuler_yxz(q)); 246 vec3 p6 = q6.transform(p); 247 248 LOLUNIT_ASSERT_DOUBLES_EQUAL(p6.x, p0.x, 1e4); 249 LOLUNIT_ASSERT_DOUBLES_EQUAL(p6.y, p0.y, 1e4); 250 LOLUNIT_ASSERT_DOUBLES_EQUAL(p6.z, p0.z, 1e4); 251 } 252 } 253 254 LOLUNIT_TEST(EulerAngles) 255 { 256 257 } 191 258 }; 192 259
Note: See TracChangeset
for help on using the changeset viewer.