/usr/include/Wt/WTransform is in libwt-dev 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WTRANSFORM_H_
#define WTRANSFORM_H_
#include <Wt/WDllDefs.h>
namespace Wt {
class WPointF;
/*! \class WTransform Wt/WTransform Wt/WTransform
* \brief A 2D affine transformation matrix.
*
* The matrix is encoded using 6 parameters:
* \code
* m11 m12 0
* m21 m22 0
* dx dy 1
* \endcode
*
* In this representation, dx() (= m31()) and dy() (= m32()) represent
* the translation components, and m<i>xy</i> represent a 2D matrix
* that contains the scale, rotation (and skew) components.
*
* The transformation is used to represent a tansformed coordinate
* system, and provides methods to rotate(), scale(), shear() or
* translate() this coordinate system.
*
* There are also 2 methods to decompose an arbitrary matrix into
* elementary operations:
* - decomposeTranslateRotateScaleSkew() \htmlonly
* decomposes into a <i>T</i> ∘ <i>R</i> ∘ <i>Sxx</i>
* ∘ <i>Sxy</i>\endhtmlonly
* - decomposeTranslateRotateScaleRotate() \htmlonly
* decomposes into a <i>T</i> ∘ <i>R1</i> ∘ <i>Sxx</i>
* ∘ <i>R2</i>\endhtmlonly
*
* with <i>T</i> a translation, <i>R</i> a rotation, <i>Sxx</i> a scale, and <i>Sxy</i> a skew component.
*
* \ingroup painting
*/
class WT_API WTransform
{
public:
/*! \brief Default constructor.
*
* Creates the identity transformation matrix.
*/
WTransform();
/*! \brief Construct a custom matrix by specifying the parameters.
*
* Creates a matrix from the specified parameters.
*/
WTransform(double m11, double m12, double m21, double m22,
double dx, double dy);
/*! \brief Assignment operator.
*
* Copies the transformation from the \p rhs.
*/
WTransform& operator=(const WTransform& rhs);
#ifdef WT_TARGET_JAVA
/*! \brief Clone method.
*
* Clones this WTransform object.
*/
WTransform clone() const;
#endif
/*! \brief Comparison operator.
*
* Returns \c true if the transforms are exactly the same.
*/
bool operator==(const WTransform& rhs) const;
/*! \brief Comparison operator.
*
* Returns \c true if the transforms are different.
*/
bool operator!=(const WTransform& rhs) const;
/*! \brief Identity check.
*
* Returns true if the transform represents an identity transformation.
*/
bool isIdentity() const;
/*! \brief Returns the horizontal scaling factor.
*/
double m11() const { return m_[M11]; }
/*! \brief Returns the vertical shearing factor.
*/
double m12() const { return m_[M21]; }
/*! \brief Returns m13 = 0.
*/
double m13() const { return 0; }
/*! \brief Returns the horizontal shearing factor.
*/
double m21() const { return m_[M12]; }
/*! \brief Returns the vertical scaling factor.
*/
double m22() const { return m_[M22]; }
/*! \brief Returns m23 = 0.
*/
double m23() const { return 0; }
/*! \brief Returns the horizontal translation factor.
*
* Is equivalent to dx()
*/
double m31() const { return m_[M13]; }
/*! \brief Returns the vertical translation factor.
*
* Is equivalent to dy()
*/
double m32() const { return m_[M23]; }
/*! \brief Returns m33 = 1.
*/
double m33() const { return 1; }
/*! \brief Returns the horizontal translation factor.
*
* Is equivalent to m31()
*/
double dx() const { return m_[DX]; }
/*! \brief Returns the vertical translation factor.
*
* Is equivalent to m32()
*/
double dy() const { return m_[DY]; }
/*! \brief Applys the transformation to a point.
*
* Returns the transformed point.
*
* \sa map(double x, double y, double *tx, double *ty) const
*/
WPointF map(const WPointF& p) const;
/*! \brief Applys the transformation to a point.
*
* Sets the point (<i>tx</i>, \p ty) to the transformation of
* the point (<i>x</i>, \p y).
*
* \sa map(const WPointF&) const
*/
void map(double x, double y, double *tx, double *ty) const;
/*! \brief Resets the transformation to the identity.
*
* \sa isIdentity(), WTransform()
*/
void reset();
/*! \brief Rotates the transformation.
*
* Applies a clock-wise rotation to the current transformation
* matrix, over \p angle degrees.
*
* \sa rotateRadians()
*/
WTransform& rotate(double angle);
/*! \brief Rotates the transformation.
*
* Applies a clock-wise rotation to the current transformation
* matrix, over \p angle radians.
*
* \sa rotate()
*/
WTransform& rotateRadians(double angle);
/*! \brief Scales the transformation.
*
* Applies a clock-wise rotation to the current transformation
* matrix, over \p angle radians.
*
* \sa shear()
*/
WTransform& scale(double sx, double sy);
/*! \brief Shears the transformation.
*
* Shears the current transformation.
*
* \sa scale(), rotate()
*/
WTransform& shear(double sh, double sv);
/*! \brief Translates the transformation.
*
* Translates the current transformation.
*/
WTransform& translate(double dx, double dy);
/*! \brief Adds a transform that is conceptually applied after this transform.
*/
WTransform& operator*= (const WTransform& rhs);
/*! \brief Multiply 2 transform objects.
*/
WTransform operator* (const WTransform& rhs) const;
/*! \brief Returns the determinant.
*/
double determinant() const;
/*! \brief Returns the adjoint.
*/
WTransform adjoint() const;
/*! \brief Returns the inverted transformation.
*
* Returns \p this if the transformation could not be inverted
* (determinant() == 0), and logs an error instead.
*/
WTransform inverted() const;
/*! \brief Result of a TRSS decomposition
*
* \sa decomposeTranslateRotateScaleSkew()
*/
struct TRSSDecomposition {
double dx, //!< X component of translation
dy, //!< Y component of translation
alpha, //!< Rotation angle (radians)
sx, //!< X component of scale
sy, //!< Y component of scale
sh; //!< Shear (in Y direction)
};
/*! \brief Decomposes the transformation
*
* Decomposes the transformation into elementary operations:
* translation (<i>dx</i>, \p dy), followed by rotation
* (<i>alpha</i>), followed by scale (<i>sx</i>, \p sy) and
* vertical shearing factor (\p sh). The angle is expressed in
* radians.
*
* This performs a <a
* href="http://en.wikipedia.org/wiki/Gram_schmidt">Gram-Schmidt
* orthonormalization</a>.
*/
void decomposeTranslateRotateScaleSkew(TRSSDecomposition& result) const;
/*! \brief Result of a TRSR decomposition
*
* \sa decomposeTranslateRotateScaleRotate()
*/
struct TRSRDecomposition {
double dx, //!< X component of translation
dy, //!< Y component of translation
alpha1, //!< First rotation angle (radians)
sx, //!< X component of scale
sy, //!< Y component of scale
alpha2; //!< Second rotation angle (radians)
};
/*! \brief Decomposes the transformation
*
* Decomposes the transformation into elementary operations:
* translation (<i>dx</i>, \p dy), followed by rotation
* (<i>alpha2</i>), followed by scale (<i>sx</i>, \p sy) and
* again a rotation (\p alpha2). The angles are expressed in
* radians.
*
* This performs a <a
* href="http://en.wikipedia.org/wiki/Singular_value_decomposition">Singular
* Value Decomposition (SVD)</a>.
*/
void decomposeTranslateRotateScaleRotate(TRSRDecomposition& result) const;
/*! \brief Utility method to convert degrees to radians.
*/
static double degreesToRadians(double angle);
private:
// we use row,column indices; prepend transformations to the left,
// and transform column point vectors: X' = M.X
// by row: real 2x2 matrix:
static const int M11 = 0;
static const int M12 = 1;
static const int M21 = 2;
static const int M22 = 3;
static const int M13 = 4;
static const int DX = 4;
static const int M23 = 5;
static const int DY = 5;
double m_[6];
};
}
#endif // WTRANSFORM_H_
|