openshot-audio  0.1.7
juce_AffineTransform.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_AFFINETRANSFORM_H_INCLUDED
26 #define JUCE_AFFINETRANSFORM_H_INCLUDED
27 
28 
29 //==============================================================================
41 {
42 public:
43  //==============================================================================
46 
49 
58  AffineTransform (float mat00, float mat01, float mat02,
59  float mat10, float mat11, float mat12) noexcept;
60 
62  AffineTransform& operator= (const AffineTransform& other) noexcept;
63 
65  bool operator== (const AffineTransform& other) const noexcept;
66 
68  bool operator!= (const AffineTransform& other) const noexcept;
69 
78  static const AffineTransform identity;
79 
80  //==============================================================================
82  template <typename ValueType>
83  void transformPoint (ValueType& x, ValueType& y) const noexcept
84  {
85  const ValueType oldX = x;
86  x = static_cast<ValueType> (mat00 * oldX + mat01 * y + mat02);
87  y = static_cast<ValueType> (mat10 * oldX + mat11 * y + mat12);
88  }
89 
95  template <typename ValueType>
96  void transformPoints (ValueType& x1, ValueType& y1,
97  ValueType& x2, ValueType& y2) const noexcept
98  {
99  const ValueType oldX1 = x1, oldX2 = x2;
100  x1 = static_cast<ValueType> (mat00 * oldX1 + mat01 * y1 + mat02);
101  y1 = static_cast<ValueType> (mat10 * oldX1 + mat11 * y1 + mat12);
102  x2 = static_cast<ValueType> (mat00 * oldX2 + mat01 * y2 + mat02);
103  y2 = static_cast<ValueType> (mat10 * oldX2 + mat11 * y2 + mat12);
104  }
105 
111  template <typename ValueType>
112  void transformPoints (ValueType& x1, ValueType& y1,
113  ValueType& x2, ValueType& y2,
114  ValueType& x3, ValueType& y3) const noexcept
115  {
116  const ValueType oldX1 = x1, oldX2 = x2, oldX3 = x3;
117  x1 = static_cast<ValueType> (mat00 * oldX1 + mat01 * y1 + mat02);
118  y1 = static_cast<ValueType> (mat10 * oldX1 + mat11 * y1 + mat12);
119  x2 = static_cast<ValueType> (mat00 * oldX2 + mat01 * y2 + mat02);
120  y2 = static_cast<ValueType> (mat10 * oldX2 + mat11 * y2 + mat12);
121  x3 = static_cast<ValueType> (mat00 * oldX3 + mat01 * y3 + mat02);
122  y3 = static_cast<ValueType> (mat10 * oldX3 + mat11 * y3 + mat12);
123  }
124 
125  //==============================================================================
127  AffineTransform translated (float deltaX,
128  float deltaY) const noexcept;
129 
131  template <typename PointType>
132  AffineTransform translated (PointType delta) const noexcept
133  {
134  return translated ((float) delta.x, (float) delta.y);
135  }
136 
138  static AffineTransform translation (float deltaX,
139  float deltaY) noexcept;
140 
142  template <typename PointType>
143  static AffineTransform translation (PointType delta) noexcept
144  {
145  return translation ((float) delta.x, (float) delta.y);
146  }
147 
149  AffineTransform withAbsoluteTranslation (float translationX,
150  float translationY) const noexcept;
151 
157  AffineTransform rotated (float angleInRadians) const noexcept;
158 
164  AffineTransform rotated (float angleInRadians,
165  float pivotX,
166  float pivotY) const noexcept;
167 
169  static AffineTransform rotation (float angleInRadians) noexcept;
170 
172  static AffineTransform rotation (float angleInRadians,
173  float pivotX,
174  float pivotY) noexcept;
175 
179  AffineTransform scaled (float factorX,
180  float factorY) const noexcept;
181 
185  AffineTransform scaled (float factor) const noexcept;
186 
190  AffineTransform scaled (float factorX, float factorY,
191  float pivotX, float pivotY) const noexcept;
192 
194  static AffineTransform scale (float factorX,
195  float factorY) noexcept;
196 
198  static AffineTransform scale (float factor) noexcept;
199 
201  static AffineTransform scale (float factorX, float factorY,
202  float pivotX, float pivotY) noexcept;
203 
207  AffineTransform sheared (float shearX, float shearY) const noexcept;
208 
210  static AffineTransform shear (float shearX, float shearY) noexcept;
211 
215  static AffineTransform verticalFlip (float height) noexcept;
216 
222  AffineTransform inverted() const noexcept;
223 
230  static AffineTransform fromTargetPoints (float x00, float y00,
231  float x10, float y10,
232  float x01, float y01) noexcept;
233 
235  static AffineTransform fromTargetPoints (float sourceX1, float sourceY1, float targetX1, float targetY1,
236  float sourceX2, float sourceY2, float targetX2, float targetY2,
237  float sourceX3, float sourceY3, float targetX3, float targetY3) noexcept;
238 
239  //==============================================================================
241  AffineTransform followedBy (const AffineTransform& other) const noexcept;
242 
244  bool isIdentity() const noexcept;
245 
247  bool isSingularity() const noexcept;
248 
251  bool isOnlyTranslation() const noexcept;
252 
256  float getTranslationX() const noexcept { return mat02; }
257 
261  float getTranslationY() const noexcept { return mat12; }
262 
267  float getScaleFactor() const noexcept;
268 
269  //==============================================================================
270  /* The transform matrix is:
271 
272  (mat00 mat01 mat02)
273  (mat10 mat11 mat12)
274  ( 0 0 1 )
275  */
276  float mat00, mat01, mat02;
277  float mat10, mat11, mat12;
278 
279 
280 private:
281  //==============================================================================
283 };
284 
285 #endif // JUCE_AFFINETRANSFORM_H_INCLUDED
float mat02
Definition: juce_AffineTransform.h:276
void transformPoint(ValueType &x, ValueType &y) const noexcept
Definition: juce_AffineTransform.h:83
#define noexcept
Definition: juce_CompilerSupport.h:141
AffineTransform translated(PointType delta) const noexcept
Definition: juce_AffineTransform.h:132
#define JUCE_API
Definition: juce_StandardHeader.h:139
static const AffineTransform identity
Definition: juce_AffineTransform.h:78
float getTranslationY() const noexcept
Definition: juce_AffineTransform.h:261
static AffineTransform translation(PointType delta) noexcept
Definition: juce_AffineTransform.h:143
void transformPoints(ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2) const noexcept
Definition: juce_AffineTransform.h:96
float getTranslationX() const noexcept
Definition: juce_AffineTransform.h:256
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
Definition: juce_AffineTransform.h:40
void transformPoints(ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2, ValueType &x3, ValueType &y3) const noexcept
Definition: juce_AffineTransform.h:112
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
float mat12
Definition: juce_AffineTransform.h:277