Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AffineTransform.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OMNI_GEOMETRY_AFFINETRANSFORM_H_
20 #define OMNI_GEOMETRY_AFFINETRANSFORM_H_
21 
22 #include <QVector3D>
23 #include <QMatrix4x4>
25 #include "EulerAngles.h"
26 
27 namespace omni {
28  namespace geometry {
29  /**@brief An affine linear transform with rotation, scale and translation
30  **/
32  public:
34 
35  /// Return ref to rotation angles
37 
38  /// Return const ref to rotation angles
39  EulerAngles const& rotation() const;
40 
41  /// Set new rotation angles
42  void setRotation(EulerAngles const&);
43 
44  /// Return scale vector
45  QVector3D scale() const;
46 
47  /// Return scale factor
48  float uniformScale() const;
49 
50  /// Set new scale vector
51  void setScale(QVector3D const&);
52 
53  /// Set uniform value for scale
54  void setScale(float);
55 
56  /// Return reference to translation vector
57  QVector3D & translation();
58 
59  /// Return reference to translation vector (const)
60  QVector3D const& translation() const;
61 
62  /// Set new translation vector
63  void setTranslation(QVector3D const&);
64 
65  /// Calculate transformation matrix
66  QMatrix4x4 matrix() const;
67 
68  /// Calculate matrix for transformation around a center point
69  QMatrix4x4 matrix(QVector3D const& _center) const;
70 
71  /// Return true if rotation is enabled
72  bool rotationEnabled() const;
73 
74  /// Enable or disable rotation
75  void setRotationEnabled(bool);
76 
77  /// Return true if scaling is enabled
78  bool scaleEnabled() const;
79 
80  /// Return true if scaling is uniform (means scaling is equal for xyz)
81  bool uniformScaleEnabled() const;
82 
83  /// Set whether scaling is uniform
84  void setUniformScaleEnabled(bool);
85 
86  /// Enable or disable scale
87  void setScaleEnabled(bool);
88 
89  /// Return true if translation is enabled
90  bool translationEnabled() const;
91 
92  /// Enable or disable translation
93  void setTranslationEnabled(bool);
94 
95  /// Write transformation to stream
96  void toStream(QDataStream&) const;
97 
98  /// Read transformation from stream
99  void fromStream(QDataStream&);
100 
101  /// Test for equality
102  friend bool operator==(AffineTransform const&,
103  AffineTransform const&);
104 
105  private:
106  bool rotationEnabled_ = true;
108 
109  bool scaleEnabled_ = true;
110  bool uniformScaleEnabled_ = false;
111  QVector3D scale_;
112  float uniformScale_ = 1.0;
113 
114  bool translationEnabled_ = true;
115  QVector3D translation_;
116  };
117  }
118 
120 }
121 
123 
124 #endif /* OMNI_GEOMETRY_AFFINETRANSFORM_H_ */
bool scaleEnabled() const
Return true if scaling is enabled.
Definition: AffineTransform.cpp:115
void setTranslation(QVector3D const &)
Set new translation vector.
Definition: AffineTransform.cpp:72
bool rotationEnabled_
Definition: AffineTransform.h:106
void setUniformScaleEnabled(bool)
Set whether scaling is uniform.
Definition: AffineTransform.cpp:110
void setRotationEnabled(bool)
Enable or disable rotation.
Definition: AffineTransform.cpp:100
QMatrix4x4 matrix() const
Calculate transformation matrix.
Definition: AffineTransform.cpp:76
void fromStream(QDataStream &)
Read transformation from stream.
Definition: AffineTransform.cpp:149
bool uniformScaleEnabled_
Definition: AffineTransform.h:110
float uniformScale_
Definition: AffineTransform.h:112
QVector3D translation_
Definition: AffineTransform.h:115
void toStream(QDataStream &) const
Write transformation to stream.
Definition: AffineTransform.cpp:135
bool translationEnabled_
Definition: AffineTransform.h:114
EulerAngles & rotation()
Return ref to rotation angles.
Definition: AffineTransform.cpp:35
QVector3D & translation()
Return reference to translation vector.
Definition: AffineTransform.cpp:68
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
QVector3D scale() const
Return scale vector.
Definition: AffineTransform.cpp:43
void setRotation(EulerAngles const &)
Set new rotation angles.
Definition: AffineTransform.cpp:39
bool uniformScaleEnabled() const
Return true if scaling is uniform (means scaling is equal for xyz)
Definition: AffineTransform.cpp:105
void setTranslationEnabled(bool)
Enable or disable translation.
Definition: AffineTransform.cpp:130
bool scaleEnabled_
Definition: AffineTransform.h:109
Mixin class for a zyx Euler Angle Rotation system.
Definition: EulerAngles.h:29
void setScaleEnabled(bool)
Enable or disable scale.
Definition: AffineTransform.cpp:120
QVector3D scale_
Definition: AffineTransform.h:111
float uniformScale() const
Return scale factor.
Definition: AffineTransform.cpp:49
friend bool operator==(AffineTransform const &, AffineTransform const &)
Test for equality.
Definition: AffineTransform.cpp:162
An affine linear transform with rotation, scale and translation.
Definition: AffineTransform.h:31
bool translationEnabled() const
Return true if translation is enabled.
Definition: AffineTransform.cpp:125
AffineTransform()
Definition: AffineTransform.cpp:27
void setScale(QVector3D const &)
Set new scale vector.
Definition: AffineTransform.cpp:53
EulerAngles rotation_
Definition: AffineTransform.h:107
bool rotationEnabled() const
Return true if rotation is enabled.
Definition: AffineTransform.cpp:95