void APH_redraw(APH_application_handle h) { Bool result; cycle_data* c = (cycle_data*) h; TST_log_entry("NZC_redraw"); TST_log_pointer((void*)h); TST_log_pointer((void*)c); TST_log_pointer((void*)c->plugin); if (!PLA_acquire_glx_context(c->plugin)) return; glClearColor(myfrand(), myfrand(), myfrand(), 1.0); glClear(GL_COLOR_BUFFER_BIT); PLA_swap_glx_context(c->plugin); PLA_release_glx_context(c->plugin); }
int test_inverse() { int Error(0); float const Epsilon = 0.0001f; glm::dualquat dqid; glm::mat4x4 mid(1.0f); for (int j = 0; j < 100; ++j) { glm::mat4x4 rot = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::vec3 vt = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::mat4x4 m = glm::translate(mid, vt) * rot; glm::quat qr = glm::quat_cast(m); glm::dualquat dq(qr); glm::dualquat invdq = glm::inverse(dq); glm::dualquat r1 = invdq * dq; glm::dualquat r2 = dq * invdq; Error += glm::all(glm::epsilonEqual(r1.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r1.dual, dqid.dual, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(r2.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r2.dual, dqid.dual, Epsilon)) ? 0 : 1; // testing commutative property glm::dualquat r ( glm::quat( myfrand() * glm::pi<float>() * 2.0f, myfrand(), myfrand(), myfrand() ), glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f) ); glm::dualquat riq = (r * invdq) * dq; glm::dualquat rqi = (r * dq) * invdq; Error += glm::all(glm::epsilonEqual(riq.real, rqi.real, Epsilon)) && glm::all(glm::epsilonEqual(riq.dual, rqi.dual, Epsilon)) ? 0 : 1; } return Error; }
int test_mul() { int Error(0); float const Epsilon = 0.0001f; glm::mat4x4 mid(1.0f); for (int j = 0; j < 100; ++j) { // generate random rotations and translations and compare transformed by matrix and dualquats random points glm::vec3 vt1 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::vec3 vt2 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::mat4x4 rot1 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::mat4x4 rot2 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::mat4x4 m1 = glm::translate(mid, vt1) * rot1; glm::mat4x4 m2 = glm::translate(mid, vt2) * rot2; glm::mat4x4 m3 = m2 * m1; glm::mat4x4 m4 = m1 * m2; glm::quat qrot1 = glm::quat_cast(rot1); glm::quat qrot2 = glm::quat_cast(rot2); glm::dualquat dq1 = glm::dualquat(qrot1,vt1); glm::dualquat dq2 = glm::dualquat(qrot2,vt2); glm::dualquat dq3 = dq2 * dq1; glm::dualquat dq4 = dq1 * dq2; for (int i = 0; i < 100; ++i) { glm::vec4 src_pt = glm::vec4(myfrand() * 4.0f, myfrand() * 5.0f, myfrand() * 3.0f,1.0f); // test both multiplication orders glm::vec4 dst_pt_m3 = m3 * src_pt; glm::vec4 dst_pt_dq3 = dq3 * src_pt; glm::vec4 dst_pt_m3_i = glm::inverse(m3) * src_pt; glm::vec4 dst_pt_dq3_i = src_pt * dq3; glm::vec4 dst_pt_m4 = m4 * src_pt; glm::vec4 dst_pt_dq4 = dq4 * src_pt; glm::vec4 dst_pt_m4_i = glm::inverse(m4) * src_pt; glm::vec4 dst_pt_dq4_i = src_pt * dq4; Error += glm::all(glm::epsilonEqual(dst_pt_m3, dst_pt_dq3, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m4, dst_pt_dq4, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m3_i, dst_pt_dq3_i, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m4_i, dst_pt_dq4_i, Epsilon)) ? 0 : 1; } } return Error; }