# Changeset 2862Tweet

Ignore:
Timestamp:
Sep 3, 2013, 10:22:31 PM (6 years ago)
Message:

math: add unit tests for quat::rotate(vec3, vec3).

Location:
trunk
Files:
2 edited

Unmodified
Removed
• ## trunk/src/math/vector.cpp

 r2860 { vec3 v = cross(src, dst); v.printf(); float d = dot(src, dst) + lol::sqrt(sqlength(src) * sqlength(dst)); fprintf(stderr, "%f + %f = %f\n", dot(src, dst), lol::sqrt(sqlength(src) * sqlength(dst)), d); return normalize(quat(d, v.x, v.y, v.z));
• ## trunk/test/unit/quat.cpp

 r2852 // Lol Engine // // Copyright: (c) 2010-2011 Sam Hocevar // Copyright: (c) 2010-2013 Sam Hocevar //   This program is free software; you can redistribute it and/or //   modify it under the terms of the Do What The Fuck You Want To LOLUNIT_ASSERT_DOUBLES_EQUAL(e.z, d.z, 1e-5); } LOLUNIT_TEST(FromTwoVectors) { vec3 a(1.f, 2.f, 3.f); vec3 b(4.f, 5.f, 6.f); float ratio = length(a) / length(b); quat q = quat::rotate(a, b); /* Check that q transforms a into b */ vec3 c = q.transform(a); LOLUNIT_ASSERT_DOUBLES_EQUAL(c.x, b.x * ratio, 1e-5); LOLUNIT_ASSERT_DOUBLES_EQUAL(c.y, b.y * ratio, 1e-5); LOLUNIT_ASSERT_DOUBLES_EQUAL(c.z, b.z * ratio, 1e-5); /* Check that ~q transforms b into a */ vec3 d = (~q).transform(b); LOLUNIT_ASSERT_DOUBLES_EQUAL(d.x, a.x / ratio, 1e-5); LOLUNIT_ASSERT_DOUBLES_EQUAL(d.y, a.y / ratio, 1e-5); LOLUNIT_ASSERT_DOUBLES_EQUAL(d.z, a.z / ratio, 1e-5); } };
Note: See TracChangeset for help on using the changeset viewer.