From d0534789125d5ef8c44743b1fd9eaff21b9e7e0d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 14 Mar 2022 08:52:06 +0200 Subject: [PATCH] Rename AffineTransformation to AffineTransform This seems like a more appropriate term for the operation. --- ...finetransformation.h => affinetransform.h} | 82 +++++++++---------- source/geometry/dummy.cpp | 2 +- source/geometry/loader.h | 14 ++-- source/geometry/transformedshape.h | 12 +-- 4 files changed, 55 insertions(+), 55 deletions(-) rename source/geometry/{affinetransformation.h => affinetransform.h} (58%) diff --git a/source/geometry/affinetransformation.h b/source/geometry/affinetransform.h similarity index 58% rename from source/geometry/affinetransformation.h rename to source/geometry/affinetransform.h index e311b88..1cd4011 100644 --- a/source/geometry/affinetransformation.h +++ b/source/geometry/affinetransform.h @@ -1,5 +1,5 @@ -#ifndef MSP_GEOMETRY_AFFINETRANSFORMATION_H_ -#define MSP_GEOMETRY_AFFINETRANSFORMATION_H_ +#ifndef MSP_GEOMETRY_AFFINETRANSFORM_H_ +#define MSP_GEOMETRY_AFFINETRANSFORM_H_ #include #include "angle.h" @@ -10,37 +10,37 @@ namespace Msp { namespace Geometry { template -class AffineTransformation; +class AffineTransform; /** -Helper class to provide specialized operations for AffineTransformation. +Helper class to provide specialized operations for AffineTransform. */ template -class AffineTransformationOps +class AffineTransformOps { protected: - AffineTransformationOps() { } + AffineTransformOps() { } }; template -class AffineTransformationOps +class AffineTransformOps { protected: - AffineTransformationOps() { } + AffineTransformOps() { } public: - static AffineTransformation rotation(const Angle &); + static AffineTransform rotation(const Angle &); }; template -class AffineTransformationOps +class AffineTransformOps { protected: - AffineTransformationOps() { } + AffineTransformOps() { } public: - static AffineTransformation rotation(const Angle &, const LinAl::Vector &); + static AffineTransform rotation(const Angle &, const LinAl::Vector &); }; @@ -50,22 +50,22 @@ straightness of lines and ratios of distances. Angles and distances themselves may change. Internally this is represented by a square matrix of size D+1. */ template -class AffineTransformation: public AffineTransformationOps +class AffineTransform: public AffineTransformOps { - friend class AffineTransformationOps; + friend class AffineTransformOps; private: LinAl::Matrix matrix; public: - AffineTransformation(); + AffineTransform(); - static AffineTransformation translation(const LinAl::Vector &); - static AffineTransformation scaling(const LinAl::Vector &); - static AffineTransformation shear(const LinAl::Vector &, const LinAl::Vector &); + static AffineTransform translation(const LinAl::Vector &); + static AffineTransform scaling(const LinAl::Vector &); + static AffineTransform shear(const LinAl::Vector &, const LinAl::Vector &); - AffineTransformation &operator*=(const AffineTransformation &); - AffineTransformation &invert(); + AffineTransform &operator*=(const AffineTransform &); + AffineTransform &invert(); const LinAl::Matrix &get_matrix() const { return matrix; } operator const LinAl::Matrix &() const { return matrix; } @@ -77,34 +77,34 @@ public: }; template -inline AffineTransformation::AffineTransformation() +inline AffineTransform::AffineTransform() { this->matrix = LinAl::Matrix::identity(); } template -AffineTransformation AffineTransformation::translation(const LinAl::Vector &v) +AffineTransform AffineTransform::translation(const LinAl::Vector &v) { - AffineTransformation r; + AffineTransform r; for(unsigned i=0; i -AffineTransformation AffineTransformation::scaling(const LinAl::Vector &factors) +AffineTransform AffineTransform::scaling(const LinAl::Vector &factors) { - AffineTransformation r; + AffineTransform r; for(unsigned i=0; i -AffineTransformation AffineTransformation::shear(const LinAl::Vector &normal, const LinAl::Vector &shift) +AffineTransform AffineTransform::shear(const LinAl::Vector &normal, const LinAl::Vector &shift) { - AffineTransformation r; + AffineTransform r; for(unsigned i=0; i AffineTransformation::shear(const LinAl::Vector } template -AffineTransformation AffineTransformationOps::rotation(const Angle &angle) +AffineTransform AffineTransformOps::rotation(const Angle &angle) { - AffineTransformation r; + AffineTransform r; T c = cos(angle); T s = sin(angle); r.matrix(0, 0) = c; @@ -125,9 +125,9 @@ AffineTransformation AffineTransformationOps::rotation(const Angle -AffineTransformation AffineTransformationOps::rotation(const Angle &angle, const LinAl::Vector &axis) +AffineTransform AffineTransformOps::rotation(const Angle &angle, const LinAl::Vector &axis) { - AffineTransformation r; + AffineTransform r; LinAl::Vector axn = normalize(axis); T c = cos(angle); T s = sin(angle); @@ -145,54 +145,54 @@ AffineTransformation AffineTransformationOps::rotation(const Angle -inline AffineTransformation &AffineTransformation::operator*=(const AffineTransformation &other) +inline AffineTransform &AffineTransform::operator*=(const AffineTransform &other) { matrix *= other.get_matrix(); return *this; } template -inline AffineTransformation operator*(const AffineTransformation &at1, const AffineTransformation &at2) +inline AffineTransform operator*(const AffineTransform &at1, const AffineTransform &at2) { - AffineTransformation r = at1; + AffineTransform r = at1; return r *= at2; } template -inline AffineTransformation &AffineTransformation::invert() +inline AffineTransform &AffineTransform::invert() { matrix.invert(); return *this; } template -inline AffineTransformation invert(const AffineTransformation &at) +inline AffineTransform invert(const AffineTransform &at) { - AffineTransformation r = at; + AffineTransform r = at; return r.invert(); } template -inline LinAl::Vector AffineTransformation::transform(const LinAl::Vector &v) const +inline LinAl::Vector AffineTransform::transform(const LinAl::Vector &v) const { return (matrix*compose(v, T(1))).template slice(0); } template -inline LinAl::Vector AffineTransformation::transform_linear(const LinAl::Vector &v) const +inline LinAl::Vector AffineTransform::transform_linear(const LinAl::Vector &v) const { return (matrix*compose(v, T(0))).template slice(0); } template -inline Ray AffineTransformation::transform(const Ray &ray) const +inline Ray AffineTransform::transform(const Ray &ray) const { LinAl::Vector dir = transform_linear(ray.get_direction()); return Ray(transform(ray.get_start()), dir, ray.get_limit()*dir.norm()); } template -inline BoundingBox AffineTransformation::transform(const BoundingBox &bbox) const +inline BoundingBox AffineTransform::transform(const BoundingBox &bbox) const { LinAl::Vector min_pt; LinAl::Vector max_pt; diff --git a/source/geometry/dummy.cpp b/source/geometry/dummy.cpp index 26aad38..be685b0 100644 --- a/source/geometry/dummy.cpp +++ b/source/geometry/dummy.cpp @@ -1,4 +1,4 @@ -#include "affinetransformation.h" +#include "affinetransform.h" #include "angle.h" #include "boundingbox.h" #include "boundingsphere.h" diff --git a/source/geometry/loader.h b/source/geometry/loader.h index 2aff83f..0a9c4b5 100644 --- a/source/geometry/loader.h +++ b/source/geometry/loader.h @@ -140,7 +140,7 @@ template class TransformationLoader: public Loader { protected: - AffineTransformation transformation; + AffineTransform transformation; public: TransformationLoader(); @@ -349,7 +349,7 @@ inline void TransformationLoader::translate(const std::vector &offset) if(offset.size()!=D) throw std::invalid_argument("TransformationLoader::translate"); - transformation *= AffineTransformation::translation(LinAl::Vector(&offset[0])); + transformation *= AffineTransform::translation(LinAl::Vector(&offset[0])); } template @@ -363,10 +363,10 @@ inline void TransformationLoader::scale(const std::vector &s) LinAl::Vector us; for(unsigned i=0; i::scaling(us); + transformation *= AffineTransform::scaling(us); } else - transformation *= AffineTransformation::scaling(LinAl::Vector(&s[0])); + transformation *= AffineTransform::scaling(LinAl::Vector(&s[0])); } template @@ -375,7 +375,7 @@ inline void TransformationLoader::shear(const std::vector &s) if(s.size()!=2*D) throw std::invalid_argument("TransformationLoader::shear"); - transformation *= AffineTransformation::shear(LinAl::Vector(&s[0]), LinAl::Vector(&s[D])); + transformation *= AffineTransform::shear(LinAl::Vector(&s[0]), LinAl::Vector(&s[D])); } @@ -388,7 +388,7 @@ inline ShapeLoader >::ShapeLoader() template inline void ShapeLoader >::rotate(T a) { - TransformationLoader::transformation *= AffineTransformation::rotation(Angle::from_degrees(a)); + TransformationLoader::transformation *= AffineTransform::rotation(Angle::from_degrees(a)); } @@ -401,7 +401,7 @@ inline ShapeLoader >::ShapeLoader() template inline void ShapeLoader >::rotate(T a, T x, T y, T z) { - TransformationLoader::transformation *= AffineTransformation::rotation(Angle::from_degrees(a), LinAl::Vector(x, y, z)); + TransformationLoader::transformation *= AffineTransform::rotation(Angle::from_degrees(a), LinAl::Vector(x, y, z)); } diff --git a/source/geometry/transformedshape.h b/source/geometry/transformedshape.h index 9387123..168fbd9 100644 --- a/source/geometry/transformedshape.h +++ b/source/geometry/transformedshape.h @@ -1,7 +1,7 @@ #ifndef MSP_GEOMETRY_TRANSFORMEDSHAPE_H_ #define MSP_GEOMETRY_TRANSFORMEDSHAPE_H_ -#include "affinetransformation.h" +#include "affinetransform.h" #include "shape.h" namespace Msp { @@ -15,11 +15,11 @@ class TransformedShape: public Shape { private: Shape *shape; - AffineTransformation transformation; - AffineTransformation inverse_trans; + AffineTransform transformation; + AffineTransform inverse_trans; public: - TransformedShape(const Shape &, const AffineTransformation &); + TransformedShape(const Shape &, const AffineTransform &); TransformedShape(const TransformedShape &); TransformedShape &operator=(const TransformedShape &); ~TransformedShape(); @@ -27,7 +27,7 @@ public: virtual TransformedShape *clone() const; const Shape &get_shape() const { return *shape; } - const AffineTransformation &get_transformation() const { return transformation; } + const AffineTransform &get_transformation() const { return transformation; } virtual BoundingBox get_axis_aligned_bounding_box(unsigned = 0) const; virtual bool contains(const LinAl::Vector &) const; @@ -37,7 +37,7 @@ public: }; template -inline TransformedShape::TransformedShape(const Shape &s, const AffineTransformation &t): +inline TransformedShape::TransformedShape(const Shape &s, const AffineTransform &t): shape(s.clone()), transformation(t), inverse_trans(invert(t)) -- 2.43.0