1 #include "animation.hxx"
6 #define VERIFY_CLOSE(a, b) \
7 if( norm((a) - (b)) > 1e-5 ) \
9 std::cerr << "line " << __LINE__ << ": failed: "\
10 << #a << " != " << #b\
11 << " [" << (a) << " != " << (b) << "]" << std::endl; \
18 std::cerr << "failed: line " << __LINE__ << ": " << #a << std::endl; \
25 AnimationTest(const SGPropertyNode* n):
31 readRotationCenterAndAxis(center, axis);
38 int main(int argc, char* argv[])
40 SGPropertyNode_ptr config = new SGPropertyNode;
41 AnimationTest anim(config);
45 config->setDoubleValue("axis/x1-m", v1.x());
46 config->setDoubleValue("axis/y1-m", v1.y());
47 config->setDoubleValue("axis/z1-m", v1.z());
48 config->setDoubleValue("axis/x2-m", v2.x());
49 config->setDoubleValue("axis/y2-m", v2.y());
50 config->setDoubleValue("axis/z2-m", v2.z());
53 VERIFY_CLOSE(anim.center, (v1 + v2) * 0.5)
54 VERIFY_CLOSE(anim.axis, normalize(v2 - v1))
56 config->removeChild("axis", 0, false);
57 config->setDoubleValue("center/x-m", v1.x());
58 config->setDoubleValue("center/y-m", v1.y());
59 config->setDoubleValue("center/z-m", v1.z());
60 config->setDoubleValue("axis/x", v2.x());
61 config->setDoubleValue("axis/y", v2.y());
62 config->setDoubleValue("axis/z", v2.z());
65 VERIFY_CLOSE(anim.center, v1)
66 VERIFY_CLOSE(anim.axis, normalize(v2))