OpenStructure
transform.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GEOM_TRANSFORM_HH
20 #define OST_GEOM_TRANSFORM_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <ost/config.hh>
27 
28 #include "module_config.hh"
29 #include "vec3.hh"
30 #include "vec4.hh"
31 #include "mat3.hh"
32 #include "mat.hh"
33 #include "aligned_cuboid.hh"
34 
35 namespace geom {
36 
40 public:
42 
44  void Reset() {*this=Transform();}
45 
47  Mat4 GetMatrix() const {return tm_;}
49  Mat4 GetTransposedMatrix() const {return ttm_;}
51  Mat4 GetInvertedMatrix() const {return itm_;}
52 
54  void SetCenter(const Vec3& c);
56  Vec3 GetCenter() const;
57 
58  // directly set tm, messing up rot/trans/cen !
59  void SetMatrix(const Mat4& m);
60 
62 
63  void ApplyXAxisRotation(float delta);
65  void ApplyYAxisRotation(float delta);
66  void ApplyZAxisRotation(float delta);
67  void ApplyAxisRotation(float delta, const Vec3& axis);
68 
69  Mat3 GetXAxisRotation(float delta);
70  Mat3 GetYAxisRotation(float delta);
71  Mat3 GetZAxisRotation(float delta);
72 
73  Mat3 GetRot() const;
74  void SetRot(const Mat3& r);
76 
78  void ApplyXAxisTranslation(float delta);
79  void ApplyYAxisTranslation(float delta);
80  void ApplyZAxisTranslation(float delta);
81  void SetTrans(const Vec3& t);
82  Vec3 GetTrans() const;
84 
85  // apply to a vec3 and return result
86  Vec3 Apply(const Vec3& v) const;
87  // apply to a vec4 and return result
88  Vec4 Apply(const Vec4& v) const;
89  // apply inverse to a vec3 and return result
90  Vec3 ApplyInverse(const Vec3& v) const;
91  // apply inverse to a vec4 and return result
92  Vec4 ApplyInverse(const Vec4& v) const;
93  // apply to an aligned cuboid and return result
95  Transform Apply(const Transform& tf) const;
96 
97 private:
98  Mat3 rot_;
99  Vec3 trans_;
100  Vec3 cen_;
101  Mat4 tm_;
102  Mat4 ttm_;
103  Mat4 itm_;
104 
105  void update_tm();
106  void update_components();
107 };
108 
109 } // ns
110 
111 #endif
axis-aligned cuboid
basic and essential transformation class, including translation, rotation and center of rotation
Definition: transform.hh:39
void ApplyYAxisRotation(float delta)
void SetMatrix(const Mat4 &m)
Vec3 ApplyInverse(const Vec3 &v) const
Vec3 Apply(const Vec3 &v) const
void Reset()
reset to identity
Definition: transform.hh:44
Vec3 GetCenter() const
retrieve center of rotation
Vec3 GetTrans() const
void ApplyYAxisTranslation(float delta)
void SetRot(const Mat3 &r)
void SetTrans(const Vec3 &t)
void ApplyZAxisRotation(float delta)
void ApplyXAxisTranslation(float delta)
translation
Mat4 GetTransposedMatrix() const
retrieve transposed transformation matrix
Definition: transform.hh:49
AlignedCuboid Apply(const AlignedCuboid &c) const
Mat4 GetMatrix() const
retrieve transformation matrix
Definition: transform.hh:47
Mat3 GetZAxisRotation(float delta)
Mat3 GetXAxisRotation(float delta)
Vec4 Apply(const Vec4 &v) const
void SetCenter(const Vec3 &c)
set center of rotation
Mat3 GetYAxisRotation(float delta)
Transform Apply(const Transform &tf) const
void ApplyZAxisTranslation(float delta)
Mat3 GetRot() const
void ApplyAxisRotation(float delta, const Vec3 &axis)
Vec4 ApplyInverse(const Vec4 &v) const
Mat4 GetInvertedMatrix() const
retrieve inverted transformation matrix
Definition: transform.hh:51
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
#define DLLEXPORT_OST_GEOM
geom::Transform Transform
Definition: transform.hh:5