Skip to content

Commit

Permalink
Remove Matrix4::getRotationForX/Y
Browse files Browse the repository at this point in the history
Even these newly-refactored methods are no longer required now that
rotateSelectionAboutAxis has been removed, since this was the only function
which called them. This is not an overall loss of functionality for Matrix4
since it is still possible to create a matrix representing a rotation around
*any* vector axis using getRotation().
  • Loading branch information
Matthew Mott committed Mar 21, 2021
1 parent 4dd7813 commit 044920c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 46 deletions.
14 changes: 0 additions & 14 deletions libs/math/Matrix4.h
Expand Up @@ -101,20 +101,6 @@ class Matrix4
*/
static Matrix4 getRotationQuantised(const Quaternion& quaternion);

/// Construct a rotation matrix about the X axis for the given angle
template<typename Unit_T> static Matrix4 getRotationAboutX(Unit_T angle)
{
double radians = angle.asRadians();
return getRotationAboutXForSinCos(sin(radians), cos(radians));
}

/// Construct a rotation matrix about the Y axis for the given angle
template<typename Unit_T> static Matrix4 getRotationAboutY(Unit_T angle)
{
double radians = angle.asRadians();
return getRotationAboutYForSinCos(sin(radians), cos(radians));
}

/// Construct a rotation matrix about the Z axis for a given angle
template<typename Unit_T> static Matrix4 getRotationAboutZ(Unit_T angle)
{
Expand Down
28 changes: 0 additions & 28 deletions test/math/Matrix4.cpp
Expand Up @@ -135,34 +135,6 @@ TEST(MathTest, ConvertDegreesAndRadians)
EXPECT_DOUBLE_EQ(twoPiBy3R.asRadians(), 2 * math::PI / 3.0);
}

TEST(MathTest, MatrixRotationAboutXDegrees)
{
math::Degrees angle(30.0);
double cosAngle = cos(angle.asRadians());
double sinAngle = sin(angle.asRadians());

// Test X rotation
auto xRot = Matrix4::getRotationAboutX(angle);
expectNear(xRot, Matrix4::byRows(1, 0, 0, 0,
0, cosAngle, -sinAngle, 0,
0, sinAngle, cosAngle, 0,
0, 0, 0, 1));
}

TEST(MathTest, MatrixRotationAboutYDegrees)
{
math::Degrees angle(45.0);
double cosAngle = cos(angle.asRadians());
double sinAngle = sin(angle.asRadians());

// Test Y rotation
auto yRot = Matrix4::getRotationAboutY(angle);
expectNear(yRot, Matrix4::byRows(cosAngle, 0, sinAngle, 0,
0, 1, 0, 0,
-sinAngle, 0, cosAngle, 0,
0, 0, 0, 1));
}

TEST(MathTest, MatrixRotationAboutZDegrees)
{
math::Degrees angle(60.0);
Expand Down
4 changes: 0 additions & 4 deletions test/math/Quaternion.cpp
Expand Up @@ -22,8 +22,6 @@ TEST(MathTest, QuaternionForXRotation)

expectNear(xRot, Quaternion(sin(angle.asRadians() / 2), 0, 0,
cos(angle.asRadians() / 2)));
expectNear(xRot,
Quaternion::createForMatrix(Matrix4::getRotationAboutX(angle)));
}

TEST(MathTest, QuaternionForYRotation)
Expand All @@ -33,8 +31,6 @@ TEST(MathTest, QuaternionForYRotation)

expectNear(yRot, Quaternion(0, sin(angle.asRadians() / 2), 0,
cos(angle.asRadians() / 2)));
expectNear(yRot,
Quaternion::createForMatrix(Matrix4::getRotationAboutY(angle)));
}

TEST(MathTest, QuaternionForZRotation)
Expand Down

0 comments on commit 044920c

Please sign in to comment.