Browse Source

Renamed Matrix4::[xyz]Rotation() to Matrix4::rotation[XYZ]().

* "Rotation around [XYZ]" makes more sense than "[XYZ] axis rotation".
 * This naming will appear in autocompletion.
 * SceneGraph transformation methods will be named similarly
   rotate[XYZ]() (because [xyz]Rotate() is weird even more).
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
b5fc786478
  1. 16
      src/Math/Matrix4.h
  2. 18
      src/Math/Test/Matrix4Test.cpp
  3. 6
      src/Math/Test/Matrix4Test.h

16
src/Math/Matrix4.h

@ -73,8 +73,8 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @param angle Rotation angle (counterclockwise, in radians)
* @param normalizedAxis Normalized rotation axis
*
* If possible, use faster alternatives like xRotation(), yRotation()
* or zRotation().
* If possible, use faster alternatives like rotationX(), rotationY()
* and rotationZ().
* @see rotation() const, Matrix3::rotation(T), Vector3::xAxis(),
* Vector3::yAxis(), Vector3::zAxis(), deg(), rad()
* @attention Assertion fails on non-normalized rotation vector and
@ -117,10 +117,10 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @param angle Rotation angle (counterclockwise, in radians)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::xAxis())`.
* @see rotation(T, const Vector3&), yRotation(), zRotation(),
* @see rotation(T, const Vector3&), rotationY(), rotationZ(),
* rotation() const, Matrix3::rotation(T), deg(), rad()
*/
static Matrix4<T> xRotation(T angle) {
static Matrix4<T> rotationX(T angle) {
T sine = std::sin(angle);
T cosine = std::cos(angle);
@ -137,10 +137,10 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @param angle Rotation angle (counterclockwise, in radians)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::yAxis())`.
* @see rotation(T, const Vector3&), xRotation(), zRotation(),
* @see rotation(T, const Vector3&), rotationX(), rotationZ(),
* rotation() const, Matrix3::rotation(T), deg(), rad()
*/
static Matrix4<T> yRotation(T angle) {
static Matrix4<T> rotationY(T angle) {
T sine = std::sin(angle);
T cosine = std::cos(angle);
@ -157,10 +157,10 @@ template<class T> class Matrix4: public Matrix<4, T> {
* @param angle Rotation angle (counterclockwise, in radians)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::zAxis())`.
* @see rotation(T, const Vector3&), xRotation(), yRotation(),
* @see rotation(T, const Vector3&), rotationX(), rotationY(),
* rotation() const, Matrix3::rotation(T), deg(), rad()
*/
static Matrix4<T> zRotation(T angle) {
static Matrix4<T> rotationZ(T angle) {
T sine = std::sin(angle);
T cosine = std::cos(angle);

18
src/Math/Test/Matrix4Test.cpp

@ -36,9 +36,9 @@ Matrix4Test::Matrix4Test() {
&Matrix4Test::translation,
&Matrix4Test::scaling,
&Matrix4Test::rotation,
&Matrix4Test::xRotation,
&Matrix4Test::yRotation,
&Matrix4Test::zRotation,
&Matrix4Test::rotationX,
&Matrix4Test::rotationY,
&Matrix4Test::rotationZ,
&Matrix4Test::rotationScalingPart,
&Matrix4Test::rotationPart,
&Matrix4Test::translationPart,
@ -108,31 +108,31 @@ void Matrix4Test::rotation() {
CORRADE_COMPARE(Matrix4::rotation(deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()), matrix);
}
void Matrix4Test::xRotation() {
void Matrix4Test::rotationX() {
Matrix4 matrix(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.90096887f, 0.43388374f, 0.0f,
0.0f, -0.43388374f, 0.90096887f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants<float>::pi()/7), Vector3::xAxis()), matrix);
CORRADE_COMPARE(Matrix4::xRotation(rad(Math::Constants<float>::pi()/7)), matrix);
CORRADE_COMPARE(Matrix4::rotationX(rad(Math::Constants<float>::pi()/7)), matrix);
}
void Matrix4Test::yRotation() {
void Matrix4Test::rotationY() {
Matrix4 matrix(0.90096887f, 0.0f, -0.43388374f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.43388374f, 0.0f, 0.90096887f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants<float>::pi()/7), Vector3::yAxis()), matrix);
CORRADE_COMPARE(Matrix4::yRotation(rad(Math::Constants<float>::pi()/7)), matrix);
CORRADE_COMPARE(Matrix4::rotationY(rad(Math::Constants<float>::pi()/7)), matrix);
}
void Matrix4Test::zRotation() {
void Matrix4Test::rotationZ() {
Matrix4 matrix( 0.90096887f, 0.43388374f, 0.0f, 0.0f,
-0.43388374f, 0.90096887f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants<float>::pi()/7), Vector3::zAxis()), matrix);
CORRADE_COMPARE(Matrix4::zRotation(rad(Math::Constants<float>::pi()/7)), matrix);
CORRADE_COMPARE(Matrix4::rotationZ(rad(Math::Constants<float>::pi()/7)), matrix);
}
void Matrix4Test::rotationScalingPart() {

6
src/Math/Test/Matrix4Test.h

@ -28,9 +28,9 @@ class Matrix4Test: public Corrade::TestSuite::Tester<Matrix4Test> {
void translation();
void scaling();
void rotation();
void xRotation();
void yRotation();
void zRotation();
void rotationX();
void rotationY();
void rotationZ();
void rotationScalingPart();
void rotationPart();
void translationPart();

Loading…
Cancel
Save