// @returns the inverse rotation matrix around the vector and point by the specified angle Matrix4x4 getInvRotMat (const Point3 &p, const Vector3 &v, const real_t a) { const real_t vZ = v[2]; const real_t vX = v[0]; const real_t theta = atan2(vZ, vX); const real_t phi = -atan2(v[1], sqrt(vX * vX + vZ * vZ)); const Matrix4x4 &transToOrigin = getInvTransMat(Vector3(p[0], p[1], p[2])); const Matrix4x4 &A = getRotYMat(theta); const Matrix4x4 &B = getRotZMat(phi); const Matrix4x4 &C = getRotXMat(a); const Matrix4x4 &invA = getInvRotYMat(theta); const Matrix4x4 &invB = getInvRotZMat(phi); const Matrix4x4 &transBack = getTransMat(Vector3(p[0], p[1], p[2])); return transBack * (invA * invB * C * B * A).getTranspose() * transToOrigin; }
// @returns the rotation matrix around the vector and point by the specified angle Matrix4x4 getRotMat (const Vector4 &p, const Vector4 &v, const REAL a) { // [PASS] REAL theta = atan2(v.z, v.x); REAL phi = -atan2(v.y, sqrt(v.x*v.x + v.z*v.z)); // translate to the origin and back Matrix4x4 Mt = getTransMat(-p); Matrix4x4 Mt_1 = getInvTransMat(-p); Matrix4x4 M1 = getRotYMat(theta); Matrix4x4 M2 = getRotZMat(phi); Matrix4x4 M3 = getRotXMat(a); Matrix4x4 M1_1 = getInvRotYMat(theta); Matrix4x4 M2_1 = getInvRotZMat(phi); return Mt_1*M1_1*M2_1*M3*M2*M1*Mt; }
// @returns the inverse rotation matrix around the vector and // point by the specified angle Matrix4x4 getInvRotMat (const Vector4 &h, const Vector4 &a, const REAL lambda) { // @DONE: [CAMTRANS] Filled in. double theta = atan2(a.z, a.x); double phi = -atan2(a.y, sqrt(a.x*a.x + a.z*a.z)); //want to translate by -h to move from h to the origin Matrix4x4 Th = getTransMat(-h); Matrix4x4 M1Inv = getInvRotYMat(theta); Matrix4x4 M2Inv = getInvRotZMat(phi); Matrix4x4 M3Inv = getInvRotXMat(lambda); Matrix4x4 M2 = getRotZMat(phi); Matrix4x4 M1 = getRotYMat(theta); Matrix4x4 ThInv = getInvTransMat(-h); Matrix4x4 result = ThInv * M1Inv * M2Inv * M3Inv * M2 * M1 * Th; return result; }
// @returns the rotation matrix around the vector and point by the specified angle Matrix4x4 getRotMat (const Vector4 &p, const Vector4 &v, const REAL a) { // @TODO: [CAMTRANS] Fill this in... REAL theta = atan2(v.z, v.x); REAL otherAngle = -atan2(v.y, sqrt(v.x*v.x+v.z*v.z)); Matrix4x4 trans = Matrix4x4(1,0,0,p.x, 0,1,0, p.y, 0,0,1, p.z, 0,0,0,1); Matrix4x4 invTrans = Matrix4x4(1,0,0, -p.x, 0,1,0, -p.y, 0,0,1, -p.z, 0,0,0,1); Matrix4x4 final = trans*getInvRotYMat(theta)*getInvRotZMat(otherAngle)*getRotXMat(a)*getRotZMat(otherAngle)*getRotYMat(theta)*invTrans; return final; }
// @returns the inverse rotation matrix about the z axis by the specified angle Matrix4x4 getInvRotZMat (const REAL radians) { return getRotZMat(-radians); // @TODO: (CAMTRANS) Fill this in... return Matrix4x4::identity(); }
// @returns the inverse rotation matrix about the z axis by the specified angle Matrix4x4 getInvRotZMat (const REAL radians) { return getRotZMat(-1*radians); }