Browse Source

MeshTools: ability to call transformPoints*() also with DualComplex.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
e8e8e67483
  1. 11
      src/MeshTools/Test/TransformTest.cpp
  2. 8
      src/MeshTools/Transform.h

11
src/MeshTools/Test/TransformTest.cpp

@ -81,27 +81,30 @@ void TransformTest::transformVectors2D() {
void TransformTest::transformVectors3D() {
auto matrix = MeshTools::transformVectors(Matrix4::rotationZ(Deg(90.0f)), points3D);
auto complex = MeshTools::transformVectors(Quaternion::rotation(Deg(90.0f), Vector3::zAxis()), points3D);
auto quaternion = MeshTools::transformVectors(Quaternion::rotation(Deg(90.0f), Vector3::zAxis()), points3D);
CORRADE_COMPARE(matrix, points3DRotated);
CORRADE_COMPARE(complex, points3DRotated);
CORRADE_COMPARE(quaternion, points3DRotated);
}
void TransformTest::transformPoints2D() {
auto matrix = MeshTools::transformPoints(
Matrix3::translation(Vector2::yAxis(-1.0f))*Matrix3::rotation(Deg(90.0f)), points2D);
auto complex = MeshTools::transformPoints(
DualComplex::translation(Vector2::yAxis(-1.0f))*DualComplex::rotation(Deg(90.0f)), points2D);
CORRADE_COMPARE(matrix, points2DRotatedTranslated);
CORRADE_COMPARE(complex, points2DRotatedTranslated);
}
void TransformTest::transformPoints3D() {
auto matrix = MeshTools::transformPoints(
Matrix4::translation(Vector3::yAxis(-1.0f))*Matrix4::rotationZ(Deg(90.0f)), points3D);
auto complex = MeshTools::transformPoints(
auto quaternion = MeshTools::transformPoints(
DualQuaternion::translation(Vector3::yAxis(-1.0f))*DualQuaternion::rotation(Deg(90.0f), Vector3::zAxis()), points3D);
CORRADE_COMPARE(matrix, points3DRotatedTranslated);
CORRADE_COMPARE(complex, points3DRotatedTranslated);
CORRADE_COMPARE(quaternion, points3DRotatedTranslated);
}
}}}

8
src/MeshTools/Transform.h

@ -19,9 +19,8 @@
* @brief Function Magnum::MeshTools::transformVectorsInPlace(), Magnum::MeshTools::transformVectors(), Magnum::MeshTools::transformPointsInPlace(), Magnum::MeshTools::transformPoints()
*/
#include "Math/Complex.h"
#include "Math/DualQuaternion.h"
#include "Math/Matrix3.h"
#include "Math/DualComplex.h"
namespace Magnum { namespace MeshTools {
@ -106,6 +105,11 @@ template<class T, class U> void transformPointsInPlace(const Math::DualQuaternio
for(auto& point: points) point = normalizedDualQuaternion.transformPointNormalized(point);
}
/** @overload */
template<class T, class U> void transformPointsInPlace(const Math::DualComplex<T>& dualComplex, U& points) {
for(auto& point: points) point = dualComplex.transformPoint(point);
}
/** @overload */
template<class T, class U> void transformPointsInPlace(const Math::Matrix3<T>& matrix, U& points) {
for(auto& point: points) point = matrix.transformPoint(point);

Loading…
Cancel
Save