Browse Source

SceneGraph: renamed {Euclidean -> Rigid}MatrixTransformation{2,3}D.

It's shorter, following changes in Math (Matrix*::invertedRigid(),
Matrix*::isRigidTransformation()).
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
8548a2e08b
  1. 8
      src/SceneGraph/CMakeLists.txt
  2. 2
      src/SceneGraph/MatrixTransformation2D.h
  3. 2
      src/SceneGraph/MatrixTransformation3D.h
  4. 4
      src/SceneGraph/Object.h
  5. 4
      src/SceneGraph/RigidMatrixTransformation2D.cpp
  6. 35
      src/SceneGraph/RigidMatrixTransformation2D.h
  7. 4
      src/SceneGraph/RigidMatrixTransformation3D.cpp
  8. 37
      src/SceneGraph/RigidMatrixTransformation3D.h
  9. 7
      src/SceneGraph/SceneGraph.h
  10. 4
      src/SceneGraph/Test/CMakeLists.txt
  11. 60
      src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp
  12. 60
      src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp

8
src/SceneGraph/CMakeLists.txt

@ -26,8 +26,8 @@
set(MagnumSceneGraph_SRCS
Animable.cpp
Camera.cpp
EuclideanMatrixTransformation2D.cpp
EuclideanMatrixTransformation3D.cpp
RigidMatrixTransformation2D.cpp
RigidMatrixTransformation3D.cpp
Object.cpp)
# Files compiled with different flags for main library and unit test library
@ -54,8 +54,8 @@ set(MagnumSceneGraph_HEADERS
Camera3D.h
Camera3D.hpp
Drawable.h
EuclideanMatrixTransformation2D.h
EuclideanMatrixTransformation3D.h
RigidMatrixTransformation2D.h
RigidMatrixTransformation3D.h
FeatureGroup.h
MatrixTransformation2D.h
MatrixTransformation3D.h

2
src/SceneGraph/MatrixTransformation2D.h

@ -38,7 +38,7 @@ namespace Magnum { namespace SceneGraph {
@brief Two-dimensional transformation implemented using matrices
Uses Math::Matrix3 as underlying type.
@see @ref scenegraph, EuclideanMatrixTransformation2D, MatrixTransformation3D
@see @ref scenegraph, RigidMatrixTransformation2D, MatrixTransformation3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>

2
src/SceneGraph/MatrixTransformation3D.h

@ -38,7 +38,7 @@ namespace Magnum { namespace SceneGraph {
@brief Three-dimensional transformation implemented using matrices
Uses Math::Matrix4 as underlying type.
@see @ref scenegraph, EuclideanMatrixTransformation3D, MatrixTransformation2D
@see @ref scenegraph, RigidMatrixTransformation3D, MatrixTransformation2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>

4
src/SceneGraph/Object.h

@ -83,8 +83,8 @@ See @ref compilation-speedup-hpp for more information.
- @ref MatrixTransformation2D "Object<MatrixTransformation2D<Float>>"
- @ref MatrixTransformation3D "Object<MatrixTransformation3D<Float>>"
- @ref EuclideanMatrixTransformation2D "Object<EuclideanMatrixTransformation2D<Float>>"
- @ref EuclideanMatrixTransformation3D "Object<EuclideanMatrixTransformation3D<Float>>"
- @ref RigidMatrixTransformation2D "Object<RigidMatrixTransformation2D<Float>>"
- @ref RigidMatrixTransformation3D "Object<RigidMatrixTransformation3D<Float>>"
@see Scene, AbstractFeature, AbstractTransformation, DebugTools::ObjectRenderer
*/

4
src/SceneGraph/EuclideanMatrixTransformation2D.cpp → src/SceneGraph/RigidMatrixTransformation2D.cpp

@ -22,14 +22,14 @@
DEALINGS IN THE SOFTWARE.
*/
#include "EuclideanMatrixTransformation2D.h"
#include "RigidMatrixTransformation2D.h"
#include "Object.hpp"
namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_SCENEGRAPH_EXPORT Object<EuclideanMatrixTransformation2D<>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<RigidMatrixTransformation2D<>>;
#endif
}}

35
src/SceneGraph/EuclideanMatrixTransformation2D.h → src/SceneGraph/RigidMatrixTransformation2D.h

@ -1,5 +1,5 @@
#ifndef Magnum_SceneGraph_EuclideanMatrixTransformation2D_h
#define Magnum_SceneGraph_EuclideanMatrixTransformation2D_h
#ifndef Magnum_SceneGraph_RigidMatrixTransformation2D_h
#define Magnum_SceneGraph_RigidMatrixTransformation2D_h
/*
This file is part of Magnum.
@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::EuclideanMatrixTransformation2D
* @brief Class Magnum::SceneGraph::RigidMatrixTransformation2D
*/
#include "Math/Matrix3.h"
@ -36,20 +36,19 @@
namespace Magnum { namespace SceneGraph {
/**
@brief Two-dimensional euclidean transformation implemented using matrices
@brief Two-dimensional rigid transformation implemented using matrices
Unlike MatrixTransformation2D this class allows only rotation, reflection and
translation (no scaling or setting arbitrary transformations). This allows to
use Matrix3::invertedEuclidean() for faster computation of inverse
transformations.
@see @ref scenegraph, EuclideanMatrixTransformation3D
use Matrix3::invertedRigid() for faster computation of inverse transformations.
@see @ref scenegraph, RigidMatrixTransformation3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
public:
/** @brief Transformation matrix type */
typedef typename DimensionTraits<2, T>::MatrixType DataType;
@ -80,7 +79,7 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* @brief Reset transformation to default
* @return Pointer to self (for method chaining)
*/
inline EuclideanMatrixTransformation2D<T>* resetTransformation() {
inline RigidMatrixTransformation2D<T>* resetTransformation() {
setTransformation({});
return this;
}
@ -92,7 +91,7 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* Normalizes the rotation part using Math::Algorithms::gramSchmidt()
* to prevent rounding errors when rotating the object subsequently.
*/
EuclideanMatrixTransformation2D<T>* normalizeRotation() {
RigidMatrixTransformation2D<T>* normalizeRotation() {
setTransformation(Math::Matrix3<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
@ -100,7 +99,7 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
}
/** @copydoc AbstractTranslationRotation2D::translate() */
inline EuclideanMatrixTransformation2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix3<T>::translation(vector), type);
return this;
}
@ -113,7 +112,7 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
*
* @see normalizeRotation(), Matrix3::rotation()
*/
inline EuclideanMatrixTransformation2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix3<T>::rotation(angle), type);
return this;
}
@ -127,7 +126,7 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
*
* @see Matrix3::reflection()
*/
inline EuclideanMatrixTransformation2D<T>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
inline RigidMatrixTransformation2D<T>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::reflection(normal), type);
return this;
}
@ -138,23 +137,23 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* if you want to move it above all.
* @return Pointer to self (for method chaining)
*/
inline EuclideanMatrixTransformation2D<T>* move(Object<EuclideanMatrixTransformation2D<T>>* under) {
static_cast<Object<EuclideanMatrixTransformation2D>*>(this)->Corrade::Containers::template LinkedList<Object<EuclideanMatrixTransformation2D<T>>>::move(this, under);
inline RigidMatrixTransformation2D<T>* move(Object<RigidMatrixTransformation2D<T>>* under) {
static_cast<Object<RigidMatrixTransformation2D>*>(this)->Corrade::Containers::template LinkedList<Object<RigidMatrixTransformation2D<T>>>::move(this, under);
return this;
}
protected:
/* Allow construction only from Object */
inline explicit EuclideanMatrixTransformation2D() = default;
inline explicit RigidMatrixTransformation2D() = default;
private:
inline void setTransformation(const Math::Matrix3<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<EuclideanMatrixTransformation2D<T>>*>(this)->isScene()) {
if(!static_cast<Object<RigidMatrixTransformation2D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<EuclideanMatrixTransformation2D<T>>*>(this)->setDirty();
static_cast<Object<RigidMatrixTransformation2D<T>>*>(this)->setDirty();
}
}

4
src/SceneGraph/EuclideanMatrixTransformation3D.cpp → src/SceneGraph/RigidMatrixTransformation3D.cpp

@ -22,14 +22,14 @@
DEALINGS IN THE SOFTWARE.
*/
#include "EuclideanMatrixTransformation3D.h"
#include "RigidMatrixTransformation3D.h"
#include "Object.hpp"
namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_SCENEGRAPH_EXPORT Object<EuclideanMatrixTransformation3D<>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<RigidMatrixTransformation3D<>>;
#endif
}}

37
src/SceneGraph/EuclideanMatrixTransformation3D.h → src/SceneGraph/RigidMatrixTransformation3D.h

@ -1,5 +1,5 @@
#ifndef Magnum_SceneGraph_EuclideanMatrixTransformation3D_h
#define Magnum_SceneGraph_EuclideanMatrixTransformation3D_h
#ifndef Magnum_SceneGraph_RigidMatrixTransformation3D_h
#define Magnum_SceneGraph_RigidMatrixTransformation3D_h
/*
This file is part of Magnum.
@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::EuclideanMatrixTransformation3D
* @brief Class Magnum::SceneGraph::RigidMatrixTransformation3D
*/
#include "Math/Matrix4.h"
@ -36,20 +36,19 @@
namespace Magnum { namespace SceneGraph {
/**
@brief Three-dimensional euclidean transformation implemented using matrices
@brief Three-dimensional rigid transformation implemented using matrices
Unlike MatrixTransformation3D this class allows only rotation, reflection and
translation (no scaling or setting arbitrary transformations). This allows to
use Matrix4::invertedEuclidean() for faster computation of inverse
transformations.
@see @ref scenegraph, EuclideanMatrixTransformation2D
use Matrix4::invertedRigid() for faster computation of inverse transformations.
@see @ref scenegraph, RigidMatrixTransformation2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
public:
/** @brief Transformation matrix type */
typedef typename DimensionTraits<3, T>::MatrixType DataType;
@ -80,7 +79,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* @brief Reset transformation to default
* @return Pointer to self (for method chaining)
*/
inline EuclideanMatrixTransformation3D<T>* resetTransformation() {
inline RigidMatrixTransformation3D<T>* resetTransformation() {
setTransformation({});
return this;
}
@ -92,7 +91,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Normalizes the rotation part using Math::Algorithms::gramSchmidt()
* to prevent rounding errors when rotating the object subsequently.
*/
EuclideanMatrixTransformation3D<T>* normalizeRotation() {
RigidMatrixTransformation3D<T>* normalizeRotation() {
setTransformation(Math::Matrix4<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
@ -108,7 +107,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis(),
* Matrix4::translation()
*/
inline EuclideanMatrixTransformation3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix4<T>::translation(vector), type);
return this;
}
@ -124,7 +123,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Vector3::yAxis(), Vector3::zAxis(), normalizeRotation(),
* Matrix4::rotation()
*/
inline EuclideanMatrixTransformation3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
return this;
}
@ -137,7 +136,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
*
* @see normalizeRotation(), Matrix4::rotationX()
*/
inline EuclideanMatrixTransformation3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix4<T>::rotationX(angle), type);
return this;
}
@ -150,7 +149,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
*
* @see normalizeRotation(), Matrix4::rotationY()
*/
inline EuclideanMatrixTransformation3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix4<T>::rotationY(angle), type);
return this;
}
@ -163,7 +162,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
*
* @see normalizeRotation(), Matrix4::rotationZ()
*/
inline EuclideanMatrixTransformation3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
inline RigidMatrixTransformation3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) override {
transform(Math::Matrix4<T>::rotationZ(angle), type);
return this;
}
@ -177,23 +176,23 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
*
* @see Matrix4::reflection()
*/
inline EuclideanMatrixTransformation3D<T>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
inline RigidMatrixTransformation3D<T>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::reflection(normal), type);
return this;
}
protected:
/* Allow construction only from Object */
inline explicit EuclideanMatrixTransformation3D() = default;
inline explicit RigidMatrixTransformation3D() = default;
private:
inline void setTransformation(const Math::Matrix4<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<EuclideanMatrixTransformation3D<T>>*>(this)->isScene()) {
if(!static_cast<Object<RigidMatrixTransformation3D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<EuclideanMatrixTransformation3D<T>>*>(this)->setDirty();
static_cast<Object<RigidMatrixTransformation3D<T>>*>(this)->setDirty();
}
}

7
src/SceneGraph/SceneGraph.h

@ -98,9 +98,6 @@ template<class T = Float> using Drawable2D = Drawable<2, T>;
template<class T = Float> using Drawable3D = Drawable<3, T>;
#endif
template<class T = Float> class EuclideanMatrixTransformation2D;
template<class T = Float> class EuclideanMatrixTransformation3D;
template<UnsignedInt dimensions, class Feature, class T = Float> class FeatureGroup;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class Feature, class T = Float> using FeatureGroup2D = FeatureGroup<2, Feature, T>;
@ -119,6 +116,10 @@ template<class T = Float> class MatrixTransformation2D;
template<class T = Float> class MatrixTransformation3D;
template<class Transformation> class Object;
template<class T = Float> class RigidMatrixTransformation2D;
template<class T = Float> class RigidMatrixTransformation3D;
template<class Transformation> class Scene;
#endif

4
src/SceneGraph/Test/CMakeLists.txt

@ -24,9 +24,9 @@
corrade_add_test(SceneGraphAnimableTest AnimableTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphCameraTest CameraTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphEuclideanMatrixTr___2DTest EuclideanMatrixTransformation2DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphEuclideanMatrixTr___3DTest EuclideanMatrixTransformation3DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphMatrixTransformation2DTest MatrixTransformation2DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphMatrixTransformation3DTest MatrixTransformation3DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphObjectTest ObjectTest.cpp LIBRARIES MagnumSceneGraphTestLib)
corrade_add_test(SceneGraphRigidMatrixTransfor___2DTest RigidMatrixTransformation2DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphRigidMatrixTransfor___3DTest RigidMatrixTransformation3DTest.cpp LIBRARIES MagnumSceneGraph)
corrade_add_test(SceneGraphSceneTest SceneTest.cpp LIBRARIES MagnumSceneGraph)

60
src/SceneGraph/Test/EuclideanMatrixTransformation2DTest.cpp → src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp

@ -24,17 +24,17 @@
#include <TestSuite/Tester.h>
#include "SceneGraph/EuclideanMatrixTransformation2D.h"
#include "SceneGraph/RigidMatrixTransformation2D.h"
#include "SceneGraph/Scene.h"
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<EuclideanMatrixTransformation2D<>> Object2D;
typedef Scene<EuclideanMatrixTransformation2D<>> Scene2D;
typedef Object<RigidMatrixTransformation2D<>> Object2D;
typedef Scene<RigidMatrixTransformation2D<>> Scene2D;
class EuclideanMatrixTransformation2DTest: public Corrade::TestSuite::Tester {
class RigidMatrixTransformation2DTest: public Corrade::TestSuite::Tester {
public:
explicit EuclideanMatrixTransformation2DTest();
explicit RigidMatrixTransformation2DTest();
void fromMatrix();
void toMatrix();
@ -48,41 +48,41 @@ class EuclideanMatrixTransformation2DTest: public Corrade::TestSuite::Tester {
void normalizeRotation();
};
EuclideanMatrixTransformation2DTest::EuclideanMatrixTransformation2DTest() {
addTests({&EuclideanMatrixTransformation2DTest::fromMatrix,
&EuclideanMatrixTransformation2DTest::toMatrix,
&EuclideanMatrixTransformation2DTest::compose,
&EuclideanMatrixTransformation2DTest::inverted,
&EuclideanMatrixTransformation2DTest::setTransformation,
&EuclideanMatrixTransformation2DTest::translate,
&EuclideanMatrixTransformation2DTest::rotate,
&EuclideanMatrixTransformation2DTest::reflect,
&EuclideanMatrixTransformation2DTest::normalizeRotation});
RigidMatrixTransformation2DTest::RigidMatrixTransformation2DTest() {
addTests({&RigidMatrixTransformation2DTest::fromMatrix,
&RigidMatrixTransformation2DTest::toMatrix,
&RigidMatrixTransformation2DTest::compose,
&RigidMatrixTransformation2DTest::inverted,
&RigidMatrixTransformation2DTest::setTransformation,
&RigidMatrixTransformation2DTest::translate,
&RigidMatrixTransformation2DTest::rotate,
&RigidMatrixTransformation2DTest::reflect,
&RigidMatrixTransformation2DTest::normalizeRotation});
}
void EuclideanMatrixTransformation2DTest::fromMatrix() {
void RigidMatrixTransformation2DTest::fromMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::fromMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation2D<>::fromMatrix(m), m);
}
void EuclideanMatrixTransformation2DTest::toMatrix() {
void RigidMatrixTransformation2DTest::toMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::toMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation2D<>::toMatrix(m), m);
}
void EuclideanMatrixTransformation2DTest::compose() {
void RigidMatrixTransformation2DTest::compose() {
Matrix3 parent = Matrix3::rotation(Deg(17.0f));
Matrix3 child = Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(RigidMatrixTransformation2D<>::compose(parent, child), parent*child);
}
void EuclideanMatrixTransformation2DTest::inverted() {
void RigidMatrixTransformation2DTest::inverted() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::inverted(m)*m, Matrix3());
CORRADE_COMPARE(RigidMatrixTransformation2D<>::inverted(m)*m, Matrix3());
}
void EuclideanMatrixTransformation2DTest::setTransformation() {
void RigidMatrixTransformation2DTest::setTransformation() {
/* Dirty after setting transformation */
Object2D o;
o.setClean();
@ -97,7 +97,7 @@ void EuclideanMatrixTransformation2DTest::setTransformation() {
CORRADE_COMPARE(s.transformationMatrix(), Matrix3());
}
void EuclideanMatrixTransformation2DTest::translate() {
void RigidMatrixTransformation2DTest::translate() {
{
Object2D o;
o.rotate(Deg(17.0f));
@ -111,7 +111,7 @@ void EuclideanMatrixTransformation2DTest::translate() {
}
}
void EuclideanMatrixTransformation2DTest::rotate() {
void RigidMatrixTransformation2DTest::rotate() {
{
Object2D o;
o.translate({1.0f, -0.3f});
@ -125,7 +125,7 @@ void EuclideanMatrixTransformation2DTest::rotate() {
}
}
void EuclideanMatrixTransformation2DTest::reflect() {
void RigidMatrixTransformation2DTest::reflect() {
{
Object2D o;
o.rotate(Deg(17.0f));
@ -139,7 +139,7 @@ void EuclideanMatrixTransformation2DTest::reflect() {
}
}
void EuclideanMatrixTransformation2DTest::normalizeRotation() {
void RigidMatrixTransformation2DTest::normalizeRotation() {
Object2D o;
o.rotate(Deg(17.0f));
o.normalizeRotation();
@ -148,4 +148,4 @@ void EuclideanMatrixTransformation2DTest::normalizeRotation() {
}}}
CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::EuclideanMatrixTransformation2DTest)
CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::RigidMatrixTransformation2DTest)

60
src/SceneGraph/Test/EuclideanMatrixTransformation3DTest.cpp → src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp

@ -24,17 +24,17 @@
#include <TestSuite/Tester.h>
#include "SceneGraph/EuclideanMatrixTransformation3D.h"
#include "SceneGraph/RigidMatrixTransformation3D.h"
#include "SceneGraph/Scene.h"
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<EuclideanMatrixTransformation3D<>> Object3D;
typedef Scene<EuclideanMatrixTransformation3D<>> Scene3D;
typedef Object<RigidMatrixTransformation3D<>> Object3D;
typedef Scene<RigidMatrixTransformation3D<>> Scene3D;
class EuclideanMatrixTransformation3DTest: public Corrade::TestSuite::Tester {
class RigidMatrixTransformation3DTest: public Corrade::TestSuite::Tester {
public:
explicit EuclideanMatrixTransformation3DTest();
explicit RigidMatrixTransformation3DTest();
void fromMatrix();
void toMatrix();
@ -48,41 +48,41 @@ class EuclideanMatrixTransformation3DTest: public Corrade::TestSuite::Tester {
void normalizeRotation();
};
EuclideanMatrixTransformation3DTest::EuclideanMatrixTransformation3DTest() {
addTests({&EuclideanMatrixTransformation3DTest::fromMatrix,
&EuclideanMatrixTransformation3DTest::toMatrix,
&EuclideanMatrixTransformation3DTest::compose,
&EuclideanMatrixTransformation3DTest::inverted,
&EuclideanMatrixTransformation3DTest::setTransformation,
&EuclideanMatrixTransformation3DTest::translate,
&EuclideanMatrixTransformation3DTest::rotate,
&EuclideanMatrixTransformation3DTest::reflect,
&EuclideanMatrixTransformation3DTest::normalizeRotation});
RigidMatrixTransformation3DTest::RigidMatrixTransformation3DTest() {
addTests({&RigidMatrixTransformation3DTest::fromMatrix,
&RigidMatrixTransformation3DTest::toMatrix,
&RigidMatrixTransformation3DTest::compose,
&RigidMatrixTransformation3DTest::inverted,
&RigidMatrixTransformation3DTest::setTransformation,
&RigidMatrixTransformation3DTest::translate,
&RigidMatrixTransformation3DTest::rotate,
&RigidMatrixTransformation3DTest::reflect,
&RigidMatrixTransformation3DTest::normalizeRotation});
}
void EuclideanMatrixTransformation3DTest::fromMatrix() {
void RigidMatrixTransformation3DTest::fromMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::fromMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation3D<>::fromMatrix(m), m);
}
void EuclideanMatrixTransformation3DTest::toMatrix() {
void RigidMatrixTransformation3DTest::toMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::toMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation3D<>::toMatrix(m), m);
}
void EuclideanMatrixTransformation3DTest::compose() {
void RigidMatrixTransformation3DTest::compose() {
Matrix4 parent = Matrix4::rotationX(Deg(17.0f));
Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(RigidMatrixTransformation3D<>::compose(parent, child), parent*child);
}
void EuclideanMatrixTransformation3DTest::inverted() {
void RigidMatrixTransformation3DTest::inverted() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::inverted(m)*m, Matrix4());
CORRADE_COMPARE(RigidMatrixTransformation3D<>::inverted(m)*m, Matrix4());
}
void EuclideanMatrixTransformation3DTest::setTransformation() {
void RigidMatrixTransformation3DTest::setTransformation() {
/* Dirty after setting transformation */
Object3D o;
o.setClean();
@ -97,7 +97,7 @@ void EuclideanMatrixTransformation3DTest::setTransformation() {
CORRADE_COMPARE(s.transformationMatrix(), Matrix4());
}
void EuclideanMatrixTransformation3DTest::translate() {
void RigidMatrixTransformation3DTest::translate() {
{
Object3D o;
o.rotateX(Deg(17.0f));
@ -111,7 +111,7 @@ void EuclideanMatrixTransformation3DTest::translate() {
}
}
void EuclideanMatrixTransformation3DTest::rotate() {
void RigidMatrixTransformation3DTest::rotate() {
{
Object3D o;
o.translate({1.0f, -0.3f, 2.3f});
@ -141,7 +141,7 @@ void EuclideanMatrixTransformation3DTest::rotate() {
}
}
void EuclideanMatrixTransformation3DTest::reflect() {
void RigidMatrixTransformation3DTest::reflect() {
{
Object3D o;
o.rotateX(Deg(17.0f));
@ -155,7 +155,7 @@ void EuclideanMatrixTransformation3DTest::reflect() {
}
}
void EuclideanMatrixTransformation3DTest::normalizeRotation() {
void RigidMatrixTransformation3DTest::normalizeRotation() {
Object3D o;
o.rotateX(Deg(17.0f));
o.normalizeRotation();
@ -164,4 +164,4 @@ void EuclideanMatrixTransformation3DTest::normalizeRotation() {
}}}
CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::EuclideanMatrixTransformation3DTest)
CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::RigidMatrixTransformation3DTest)
Loading…
Cancel
Save