void jointToWorldTest() { Joint j0, j1, j2; // J0 Setup j0.name = "J0"; j0.parentIndex = -1; j0.position = vec3(0, 0, 0); j0.orientation = quat(1, 0, 0, 0); // Identity quaternion // J1 Setup j1.name = "J1"; j1.parentIndex = 0; j1.position.x = 70.1f; j1.position.y = 70.1f; j1.orientation = glm::quat_cast(glm::rotate(mat4(), 45.0f, vec3(0, 0, 1))); j2.name = "J2"; j2.parentIndex = 1; //j2.position.x = 70.1f; j2.position.x = 0; j2.position.y = 100.0f; //j2.orientation = glm::quat_cast(glm::rotate(mat4(), 45.0f, vec3(0, 0, 1))); Skeleton skeleton; skeleton.joints.push_back(j0); skeleton.joints.push_back(j1); skeleton.joints.push_back(j2); buildJointToWorldMatrices(skeleton); //mat4 worldM = jointToWorld(skeleton, j2); //cout << "World coordinate: " << worldM[3][0] << ", " << worldM[3][1] << ", " << worldM[3][2] << endl; }
TEST( CollisionLibrary, EntitySetGet ) { ICollisionEntity* entity = g_CollisionDetection.CreateEntity(); const vec3 setPosition = vec3( -3.0f, -11.0f, 7.0f ); const quat setOrientation = quat( 0.0f, 0.0f, 1.0f, 0.0f ); const float setScale = 2.0f; entity->SetPosition ( setPosition ); entity->SetOrientation ( setOrientation ); entity->SetScale ( setScale ); EXPECT_EQ( setPosition, entity->GetPosition() ); EXPECT_EQ( setOrientation, entity->GetOrientation() ); EXPECT_EQ( setScale, entity->GetScale() ); g_CollisionDetection.DestroyEntity( entity ); g_CollisionDetection.Shutdown(); }
void easygl::init() { target = vec3(0, 1, 0); up = vec3(0, 1, 0); orientation = quat(); direction = vec3(0, 0, -1); right = cross(up, direction); up = cross(direction, right); position = vec3(5.0f, 5.0f, 5.0f); fieldOfView = 60.0f; near = 0.1f, far = 1000.0f; aspectRatio = 1.0; dragl = false; dragr = false; //sphere.load("sphere.stl", vec4(1.0f, 0.0f, 1.0f, 1.0f)); for(layer &l : d.layers){ l.findcontours(); l.offset(1); l.show(); } }
void LegacyMathTest::setUp() { using glm::quat; using glm::mat3; // Data from: // http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/steps/index.htm // http://www.euclideanspace.com/maths/algebra/matrix/transforms/examples/index.htm // Identity (no rotation) addTestData(quat( 1.f, 0.0f, 0.0f, 0.0f), Anglef( 0, 0, 0), mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1)); // 90 degrees about y axis addTestData(quat(0.7071f, 0.0f, 0.7071f, 0.0f), Anglef( 90, 0, 0), mat3( 0, 0, 1, 0, 1, 0, -1, 0, 0)); // 180 degrees about y axis addTestData(quat( 0.0f, 0.0f, 1.f, 0.0f), Anglef(180, 0, 0), mat3(-1, 0, 0, 0, 1, 0, 0, 0,-1)); // 270 degrees about y axis addTestData(quat(0.7071f, 0.0f,-0.7071f, 0.0f), Anglef(-90, 0, 0), mat3( 0, 0,-1, 0, 1, 0, 1, 0, 0)); addTestData(quat(0.7071f, 0.0f, 0.0f, 0.7071f), Anglef( 0, 90, 0), mat3( 0,-1, 0, 1, 0, 0, 0, 0, 1)); addTestData(quat( 0.5f, 0.5f, 0.5f, 0.5f), Anglef( 90, 90, 0), mat3( 0, 0, 1, 1, 0, 0, 0, 1, 0)); addTestData(quat( 0.0f, 0.7071f, 0.7071f, 0.0f), Anglef(180, 90, 0), mat3( 0, 1, 0, 1, 0, 0, 0, 0,-1)); addTestData(quat( 0.5f, -0.5f, -0.5f, 0.5f), Anglef(-90, 90, 0), mat3( 0, 0,-1, 1, 0, 0, 0,-1, 0)); addTestData(quat(0.7071f, 0.0f, 0.0f,-0.7071f), Anglef( 0,-90, 0), mat3( 0, 1, 0, -1, 0, 0, 0, 0, 1)); addTestData(quat( 0.5f, -0.5f, 0.5f, -0.5f), Anglef( 90,-90, 0), mat3( 0, 0, 1, -1, 0, 0, 0,-1, 0)); addTestData(quat( 0.0f,-0.7071f, 0.7071f, 0.0f), Anglef(180,-90, 0), mat3( 0,-1, 0, -1, 0, 0, 0, 0,-1)); addTestData(quat( 0.5f, 0.5f, -0.5f, -0.5f), Anglef(-90,-90, 0), mat3( 0, 0,-1, -1, 0, 0, 0, 1, 0)); addTestData(quat(0.7071f, 0.7071f, 0.0f, 0.0f), Anglef( 0, 0, 90), mat3( 1, 0, 0, 0, 0,-1, 0, 1, 0)); addTestData(quat( 0.5f, 0.5f, 0.5f, -0.5f), Anglef( 90, 0, 90), mat3( 0, 1, 0, 0, 0,-1, -1, 0, 0)); addTestData(quat( 0.0f, 0.0f, 0.7071f,-0.7071f), Anglef(180, 0, 90), mat3(-1, 0, 0, 0, 0,-1, 0,-1, 0)); addTestData(quat( 0.5f, 0.5f, -0.5f, 0.5f), Anglef(-90, 0, 90), mat3( 0,-1, 0, 0, 0,-1, 1, 0, 0)); addTestData(quat( 0.0f, 1.0f, 0.0f, 0.0f), Anglef( 0, 0,180), mat3( 1, 0, 0, 0,-1, 0, 0, 0,-1)); addTestData(quat( 0.0f, 0.7071f, 0.0f,-0.7071f), Anglef( 90, 0,180), mat3( 0, 0,-1, 0,-1, 0, -1, 0, 0)); addTestData(quat( 0.0f, 0.0f, 0.0f, 1.0f), Anglef(180, 0,180), mat3(-1, 0, 0, 0,-1, 0, 0, 0, 1)); addTestData(quat( 0.0f, 0.7071f, 0.0f, 0.7071f), Anglef(-90, 0,180), mat3( 0, 0, 1, 0,-1, 0, 1, 0, 0)); addTestData(quat(0.7071f,-0.7071f, 0.0f, 0.0f), Anglef( 0, 0,-90), mat3( 1, 0, 0, 0, 0, 1, 0,-1, 0)); addTestData(quat( 0.5f, -0.5f, 0.5f, 0.5f), Anglef( 90, 0,-90), mat3( 0,-1, 0, 0, 0, 1, -1, 0, 0)); addTestData(quat( 0.0f, 0.0f, 0.7071f, 0.7071f), Anglef(180, 0,-90), mat3(-1, 0, 0, 0, 0, 1, 0, 1, 0)); addTestData(quat( 0.5f, -0.5f, -0.5f, -0.5f), Anglef(-90, 0,-90), mat3( 0, 1, 0, 0, 0, 1, 1, 0, 0)); }