CUGL 2.1
Cornell University Game Library
|
#include <CUAffine2.h>
Public Member Functions | |
Affine2 () | |
Affine2 (float m11, float m12, float m21, float m22, float tx, float ty) | |
Affine2 (const float *mat) | |
Affine2 (const Affine2 ©) | |
Affine2 (Affine2 &©) | |
~Affine2 () | |
Affine2 & | operator= (const Affine2 &mat) |
Affine2 & | operator= (Affine2 &&mat) |
Affine2 & | operator= (const float *array) |
Affine2 & | set (float m11, float m12, float m21, float m22, float tx, float ty) |
Affine2 & | set (const float *mat) |
Affine2 & | set (const float *mat, size_t stride) |
Affine2 & | set (const Affine2 &mat) |
Affine2 & | setIdentity () |
Affine2 & | setZero () |
Affine2 * | multiply (const Mat4 &m1, const Affine2 &m2, Affine2 *dst) |
Affine2 & | add (const Vec2 v) |
Affine2 & | subtract (const Vec2 v) |
Affine2 & | multiply (float scalar) |
Affine2 & | multiply (const Affine2 &aff) |
Affine2 & | multiply (const Mat4 &mat) |
Affine2 & | invert () |
Affine2 | getInverse () const |
Affine2 & | operator+= (const Vec2 v) |
Affine2 & | operator-= (const Vec2 v) |
Affine2 & | operator*= (float scalar) |
Affine2 & | operator*= (const Mat4 &mat) |
Affine2 & | operator*= (const Affine2 &aff) |
Affine2 | operator+ (const Vec2 v) const |
Affine2 | operator- (const Vec2 v) const |
Affine2 | operator* (float scalar) const |
Affine2 | operator* (const Affine2 &aff) const |
Affine2 | operator* (const Mat4 &mat) const |
bool | isExactly (const Affine2 &aff) const |
bool | equals (const Affine2 &mat, float variance=CU_MATH_EPSILON) const |
bool | operator== (const Affine2 &aff) const |
bool | operator!= (const Affine2 &aff) const |
float * | get3x3 (float *array) const |
float * | get3x4 (float *array) const |
float * | get4x4 (float *array) const |
float * | get (float *array, size_t stride=2) const |
bool | isIdentity (float variance=0.0f) const |
bool | isInvertible (float variance=CU_MATH_EPSILON) const |
float | getDeterminant () const |
Vec2 | getScale () const |
float | getRotation () const |
Vec2 | getTranslation () const |
Vec2 | transform (const Vec2 point) const |
Rect | transform (const Rect rect) const |
Affine2 & | rotate (float angle) |
Affine2 & | scale (float value) |
Affine2 & | scale (const Vec2 s) |
Affine2 & | scale (float sx, float sy) |
Affine2 & | translate (const Vec2 t) |
Affine2 & | translate (float tx, float ty) |
std::string | toString (bool verbose=false) const |
operator std::string () const | |
operator Mat4 () const | |
Affine2 (const Mat4 &mat) | |
Affine2 & | operator= (const Mat4 &mat) |
Affine2 & | set (const Mat4 &mat) |
Static Public Member Functions | |
static Affine2 | createScale (float scale) |
static Affine2 * | createScale (float scale, Affine2 *dst) |
static Affine2 | createScale (float sx, float sy) |
static Affine2 * | createScale (float sx, float sy, Affine2 *dst) |
static Affine2 | createScale (const Vec2 scale) |
static Affine2 * | createScale (const Vec2 scale, Affine2 *dst) |
static Affine2 | createRotation (float angle) |
static Affine2 * | createRotation (float angle, Affine2 *dst) |
static Affine2 | createTranslation (const Vec2 trans) |
static Affine2 * | createTranslation (const Vec2 trans, Affine2 *dst) |
static Affine2 | createTranslation (float tx, float ty) |
static Affine2 * | createTranslation (float tx, float ty, Affine2 *dst) |
static Affine2 * | add (const Affine2 &m, const Vec2 v, Affine2 *dst) |
static float * | add (const float *m, const Vec2 v, float *dst, size_t stride=2) |
static Affine2 * | subtract (const Affine2 &m1, const Vec2 v, Affine2 *dst) |
static float * | subtract (const float *m1, const Vec2 v, float *dst, size_t stride=2) |
static Affine2 * | multiply (const Affine2 &mat, float scalar, Affine2 *dst) |
static float * | multiply (const float *mat, float scalar, float *dst, size_t stride=2) |
static Affine2 * | multiply (const Affine2 &m1, const Affine2 &m2, Affine2 *dst) |
static Affine2 * | multiply (const Affine2 &m1, const Mat4 &m2, Affine2 *dst) |
static float * | multiply (const float *m1, const float *m2, float *dst, size_t stride=2) |
static Affine2 * | invert (const Affine2 &m1, Affine2 *dst) |
static float * | invert (const float *m1, float *dst, size_t stride=2) |
static Vec2 * | transform (const Affine2 &aff, const Vec2 point, Vec2 *dst) |
static float * | transform (const Affine2 &aff, float const *input, float *output, size_t size) |
static Rect * | transform (const Affine2 &aff, const Rect rect, Rect *dst) |
static Affine2 * | identify (float *dst, size_t stride=2) |
static Affine2 * | rotate (const Affine2 &aff, float angle, Affine2 *dst) |
static float * | rotate (const float *aff, float angle, float *dst, size_t stride=2) |
static Affine2 * | scale (const Affine2 &aff, float value, Affine2 *dst) |
static float * | scale (const float *aff, float value, float *dst, size_t stride=2) |
static Affine2 * | scale (const Affine2 &aff, const Vec2 s, Affine2 *dst) |
static float * | scale (const float *aff, const Vec2 s, float *dst, size_t stride=2) |
static Affine2 * | scale (const Affine2 &aff, float sx, float sy, Affine2 *dst) |
static float * | scale (const float *aff, float sx, float sy, float *dst, size_t stride=2) |
static Affine2 * | translate (const Affine2 &aff, const Vec2 t, Affine2 *dst) |
static float * | translate (const float *aff, const Vec2 t, float *dst, size_t stride=2) |
static Affine2 * | translate (const Affine2 &aff, float tx, float ty, Affine2 *dst) |
static float * | translate (const float *aff, float tx, float ty, float *dst, size_t stride=2) |
static bool | decompose (const Affine2 &mat, Vec2 *scale, float *rot, Vec2 *trans) |
Public Attributes | |
float | m [6] |
Static Public Attributes | |
static const Affine2 | ZERO |
static const Affine2 | ONE |
static const Affine2 | IDENTITY |
This class defines an affine transform on 2D space.
In the case where you are only manipulating 2D points, this class may be faster than Mat4, even with the vectorization support. For an affine transform in 3d space, use Mat4.
An affine transform is represeted by 3x2 matrix in column major order, keeping with the convention of Mat4. The last column is the translation offset. In addition, we assume that all operations are multiplied on the right.
Because of OpenGL alignment issues, an affine transform typically needs to be converted to a 3x3 matrix (for Shader or a 3x4 matrix (for a UniformBuffer). For that reason this class contains several static methods for processing float arrays of different strides. These methods interpret stride pairwise. For example, a stride of 4 corresponds to a 3x4 matrix with the first two elements at position 0 and 1, the next two at 4 and 5, and the last two at 8 and 9.
While an affine transform corresponds to a 3x3 matrix in homongeneous coordinates, this class is not an arbitrary Mat3 class. It enforces that its contents are always an affine transform.
cugl::Affine2::Affine2 | ( | ) |
Creates the identity transform.
1 0 0 0 1 0
cugl::Affine2::Affine2 | ( | float | m11, |
float | m12, | ||
float | m21, | ||
float | m22, | ||
float | tx, | ||
float | ty | ||
) |
Constructs a matrix initialized to the specified values.
m11 | The first element of the first row. |
m12 | The second element of the first row. |
m21 | The first element of the second row. |
m22 | The second element of the second row. |
tx | The translation offset for the x-coordinate. |
ty | The translation offset for the y-coordinate. |
cugl::Affine2::Affine2 | ( | const float * | mat | ) |
Creates a matrix initialized to the specified column-major array.
The passed-in array is six elements in column-major order, with the last two elements being the translation offset. Hence the memory layout of the array is as follows:
0 2 4 1 3 5
mat | An array containing 6 elements in column-major order. |
cugl::Affine2::Affine2 | ( | const Affine2 & | copy | ) |
Constructs a new transform that is the copy of the specified one.
copy | The transform to copy. |
cugl::Affine2::Affine2 | ( | Affine2 && | copy | ) |
Constructs a new transform that contains the resources of the specified one.
copy | The transform contributing resources. |
|
inline |
Destroys this transform, releasing all resources.
|
explicit |
Creates an affine transform from the given matrix.
The z values are all uniformly ignored. However, it the final element of the matrix is not 1 (e.g. the translation has a w value of 1), then it divides the entire matrix before creating the affine transform
mat | The matrix to convert |
Adds the specified offset to the given and stores the result in dst.
Addition is applied to the offset only; the core matrix is unchanged.
m | The initial transform. |
v | The offset to add. |
dst | A transform to store the result in. |
|
static |
Adds the specified offset to the given and stores the result in dst.
Addition is applied to the offset only; the core matrix is unchanged. Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
m | The initial transform in column major order |
v | The offset to add. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
Adds the specified offset to this transform.
Addition is applied to the offset only; the core matrix is unchanged.
v | The offset to add. |
|
inlinestatic |
Returns a rotation transform for the given angle.
The angle measurement is in radians. The rotation is counter clockwise about the z-axis.
angle | The angle (in radians). |
Creates a rotation transform for the given angle, putting it in dst.
The angle measurement is in radians. The rotation is counter clockwise about the z-axis.
angle | The angle (in radians). |
dst | A transform to store the result in. |
Returns a nonuniform scale transform from the given vector.
scale | The nonuniform scale value. |
Creates a nonuniform scale transform from the given vector, putting it in dst.
scale | The nonuniform scale value. |
dst | A transform to store the result in. |
|
inlinestatic |
Returns a uniform scale transform.
scale | The amount to scale. |
Creates a uniform scale transform, putting it in dst.
scale | The amount to scale. |
dst | A transform to store the result in. |
|
inlinestatic |
Returns a nonuniform scale transform.
sx | The amount to scale along the x-axis. |
sy | The amount to scale along the y-axis. |
Creates a nonuniform scale transform, putting it in dst.
sx | The amount to scale along the x-axis. |
sy | The amount to scale along the y-axis. |
dst | A transform to store the result in. |
Returns a translation transform from the given offset
trans | The translation offset. |
Creates a translation transform from the given offset, putting it in dst.
trans | The translation offset. |
dst | A transform to store the result in. |
|
inlinestatic |
Returns a translation transform from the given parameters.
tx | The translation on the x-axis. |
ty | The translation on the y-axis. |
Creates a translation transform from the given parameters, putting it in dst.
tx | The translation on the x-axis. |
ty | The translation on the y-axis. |
dst | A transform to store the result in. |
|
static |
Decomposes the scale, rotation and translation components of the given matrix.
To work properly, the matrix must have been constructed in the following order: scale, then rotate, then translation. While the rotation matrix will always be correct, the scale and translation are not guaranteed to be correct if this is violated.
If any pointer is null, the method simply does not assign that result. However, it will still continue to compute the component with non-null vectors to store the result.
If the scale component is too small, then it may be impossible to extract the rotation. In that case, if the rotation pointer is not null, this method will return false.
mat | The transform to decompose. |
scale | The scale component. |
rot | The rotation component. |
trans | The translation component. |
bool cugl::Affine2::equals | ( | const Affine2 & | mat, |
float | variance = CU_MATH_EPSILON |
||
) | const |
Returns true if the transforms are within tolerance of each other.
The tolerance is applied to each element of the transform individually.
mat | The transform to compare against. |
variance | The comparison tolerance. |
float* cugl::Affine2::get | ( | float * | array, |
size_t | stride = 2 |
||
) | const |
Reads the affine transform as an array with the given stride
The float array should have at least 6-elements where each of the three pairs have the given stride. Postions outside of the 6 element core are left untouched.
array | The array to store the values |
stride | The pairwise data stride |
float* cugl::Affine2::get3x3 | ( | float * | array | ) | const |
Reads the affine transform as a 3x3 matrix into the given array.
The array should contain at least 9 elements. The transform is read in column major order as a 3x3 matrix in homogenous coordinates. That is, the z values are all 0, except for the translation component which is 1.
array | The array to store the values |
float* cugl::Affine2::get3x4 | ( | float * | array | ) | const |
Reads the affine transform as a 3x4 matrix into the given array.
The array should contain at least 12 elements. The transform is read in column major order as a 3x4 matrix in homogenous coordinates. That is, the z and w values are all 0, except for the translation z component which is 1.
array | The array to store the values |
float* cugl::Affine2::get4x4 | ( | float * | array | ) | const |
Reads the affine transform as a 4x4 matrix into the given array.
The array should contain at least 16 elements. The transform is read in column major order as a 4x4 matrix in homogenous coordinates. The z and w values are all 0, except for the translation w component which is 1.
array | The array to store the values |
|
inline |
Returns the determinant of this transform.
The determinant is a feature of the core matrix. The offset is ignored.
|
inline |
Returns a copy of the inverse of this transform.
If the transform cannot be inverted, this method returns the zero transform.
Note: This does not modify the transform.
|
inline |
Returns the rotational angle of this transform.
If the scale component is too close to zero, we cannot extract the rotation. In that case, we return the zero angle. (
|
inline |
Returns the scale component of this transform.
If the scale component of this matrix has negative parts, it is not possible to always extract the exact scalar component. In that case, a scale vector that is mathematically equivalent to the original scale vector is extracted and returned.
|
inline |
Returns the translational component of this transform.
|
static |
Sets the float array to be an identity affine transform.
The float arrays should have at least 6-elements where each of the three pairs have the given stride. Positions outside of the 6 core elements are untouched.
dst | The affine to reset in column major order |
stride | The pairwise data stride |
|
inline |
Inverts this transform in place.
If the transform cannot be inverted, this method sets it to the zero transform.
Inverts m1 and stores the result in dst.
If the transform cannot be inverted, this method stores the zero transform in dst.
m1 | The transform to negate. |
dst | A transform to store the result in. |
|
static |
Inverts m1 and stores the result in dst.
If the transform cannot be inverted, this method stores the zero transform in dst. Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride. When converting a matrix to the zero transform, positions outside of the 6 core elements are ignored.
m1 | The transform to negate in column major order |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
bool cugl::Affine2::isExactly | ( | const Affine2 & | aff | ) | const |
Returns true if the transforms are exactly equal to each other.
This method may be unreliable given that the elements are floats. It should only be used to compared transform that have not undergone a lot of manipulation.
aff | The transform to compare against. |
bool cugl::Affine2::isIdentity | ( | float | variance = 0.0f | ) | const |
Returns true if this transform is equal to the identity transform.
The optional comparison tolerance takes into accout that elements are floats and this may not be exact. The tolerance is applied to each element individually. By default, the match must be exact.
variance | The comparison tolerance |
|
inline |
Returns true if this transform is invertible.
The optional comparison tolerance takes into accout that elements are floats and this may not be exact. The tolerance is applied to the determinant of the core matrix.
Multiplies this matrix by the specified one.
Transform multiplication is defined as standard function composition. The transform m2 is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
aff | The transform to multiply. |
|
static |
Multiplies m1 by the transform m2 and stores the result in dst.
Transform multiplication is defined as standard function composition. The transform m2 is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
m1 | The first transform to multiply. |
m2 | The second transform to multiply. |
dst | A matrix to store the result in. |
|
static |
Multiplies m1 by the matrix m2 and stores the result in dst.
The matrix m2 is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms. The z component of m2 is ignored.
m1 | The first transform to multiply. |
m2 | The second transform to multiply. |
dst | A matrix to store the result in. |
Multiplies the specified transform by a scalar and stores the result in dst.
The scalar is applied to BOTH the core matrix and the offset.
mat | The transform. |
scalar | The scalar value. |
dst | A transform to store the result in. |
|
static |
Multiplies m1 by the transform m2 and stores the result in dst.
Transform multiplication is defined as standard function composition. The transform m2 is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
m1 | The first transform to multiply in column major order |
m2 | The second transform to multiply in column major order |
dst | A matrix to store the result in column major order |
stride | The pairwise data stride |
|
static |
Multiplies the specified transform by a scalar and stores the result in dst.
The scalar is applied to BOTH the core matrix and the offset. Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
mat | The transform in column major order |
scalar | The scalar value. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
Multiplies m1 by the matrix m2 and stores the result in dst.
The matrix m2 is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms. The z component of m2 is ignored.
m1 | The first transform to multiply. |
m2 | The second transform to multiply. |
dst | A matrix to store the result in. |
Multiplies this matrix by the specified one.
The matrix mat is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms. The z compoent of mat is ignored.
mat | The transform to multiply. |
|
inline |
Multiplies the components of this transform by the specified scalar.
The scalar is applied to BOTH the core matrix and the offset.
scalar | The scalar value. |
|
inline |
Cast from Vec4 to a string.
|
inline |
Returns true if this transform is not equal to the given transform.
Comparison is exact, which may be unreliable given that the elements are floats.
aff | The transform to compare against. |
Returns the matrix product of this matrix with the given matrix.
Transform multiplication is defined as standard function composition. The transform aff is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
Note: This does not modify the matrix.
aff | The transform to multiply by. |
Returns the matrix product of this matrix with the given matrix.
Transform multiplication is defined as standard function composition. The transform aff is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
Note: This does not modify the matrix.
mat | The transform to multiply by. |
|
inline |
Returns a copy of this matrix with all elements multiplied by the scalar.
The scalar is applied to BOTH the core matrix and the offset.
Note: This does not modify the matrix.
scalar | The scalar value. |
Right-multiplies this transform by the given transform.
Transform multiplication is defined as standard function composition. The transform aff is on the right. This means that it corresponds to an subsequent transform; transforms are applied left-to-right.
aff | The transform to multiply by. |
Right-multiplies this transform by the given matrix.
The matrix mat is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms. The z compoent of mat is ignored.
mat | The matrix to multiply by. |
|
inline |
Multiplies the components of this transform by the specified scalar.
The scalar is applied to BOTH the core matrix and the offset.
scalar | The scalar value. |
Returns the sum of this transform with the given offset.
Addition is applied to the offset only; the core matrix is unchanged.
Note: This does not modify the transform.
v | The offset to add. |
Adds the given offset to this transform in place.
Addition is applied to the offset only; the core matrix is unchanged.
v | The offset to add |
Returns the difference of this matrix with the given offset.
Subtraction is applied to the offset only; the core matrix is unchanged.
Note: This does not modify the transform.
v | The offset to subtract. |
Subtracts the given offset from this transform in place.
Subtraction is applied to the offset only; the core matrix is unchanged.
v | The offset to subtract |
Sets the elements of this matrix to those in the specified one.
mat | The matrix to take resources from. |
Sets the elements of this transform to those in the specified transform.
mat | The transform to copy. |
|
inline |
Sets the values of this transform to those in the specified column-major array.
The passed-in array is six elements in column-major order, with the last two elements being the translation offset. Hence the memory layout of the array is as follows:
0 2 4 1 3 5
array | An array containing 6 elements in column-major order. |
Sets the elements of this transform to those of the given matrix.
The z values are all uniformly ignored. However, it the final element of the matrix is not 1 (e.g. the translation has a w value of 1), then it divides the entire matrix before creating the affine transform
mat | The matrix to convert |
|
inline |
Returns true if this transform is equal to the given transform.
Comparison is exact, which may be unreliable given that the elements are floats. It should only be used to compared transform that have not undergone a lot of manipulation.
aff | The transform to compare against. |
Applies a rotation to the given transform and stores the result in dst.
The rotation is in radians, counter-clockwise about the z-axis.
The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to rotate. |
angle | The angle (in radians). |
dst | A transform to store the result in. |
|
static |
Applies a rotation to the given transform and stores the result in dst.
The rotation is in radians, counter-clockwise about the z-axis. Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to rotate in column major order |
angle | The angle (in radians). |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
|
inline |
Applies a rotation to this transform.
The rotation is in radians, counter-clockwise about the given axis.
The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
angle | The angle (in radians). |
Applies a non-uniform scale to the given transform and stores the result in dst.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale. |
s | The vector storing the individual scaling factors |
dst | A transform to store the result in. |
|
static |
Applies a non-uniform scale to the given transform and stores the result in dst.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale. |
sx | The amount to scale along the x-axis. |
sy | The amount to scale along the y-axis. |
dst | A transform to store the result in. |
Applies a uniform scale to the given transform and stores the result in dst.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale. |
value | The scalar to multiply by. |
dst | A transform to store the result in. |
|
static |
Applies a non-uniform scale to the given transform and stores the result in dst.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale in column major order |
s | The vector storing the individual scaling factors |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
|
static |
Applies a non-uniform scale to the given transform and stores the result in dst.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale in column major order |
sx | The amount to scale along the x-axis. |
sy | The amount to scale along the y-axis. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
|
static |
Applies a uniform scale to the given transform and stores the result in dst.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to scale in column major order |
value | The scalar to multiply by. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
Applies a non-uniform scale to this transform.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
s | The vector storing the individual scaling factors |
|
inline |
Applies a non-uniform scale to this transform.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
sx | The amount to scale along the x-axis. |
sy | The amount to scale along the y-axis. |
|
inline |
Applies a uniform scale to this transform.
The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
value | The scalar to multiply by. |
Sets the elements of this transform to those in the specified transform.
mat | The transform to copy. |
Affine2& cugl::Affine2::set | ( | const float * | mat | ) |
Sets the values of this transform to those in the specified column-major array.
The passed-in array is six elements in column-major order, with the last two elements being the translation offset. Hence the memory layout of the array is as follows:
0 2 4 1 3 5
mat | An array containing 6 elements in column-major order. |
Affine2& cugl::Affine2::set | ( | const float * | mat, |
size_t | stride | ||
) |
Sets the values of this transform to those in the specified column-major array.
The passed-in array is six elements grouped in pairs, with each pair separated by a stride. For example, if stride is 4, then mat is a 12-element array with the first column at 0,1, the second column at 4,5 and the translation component at 8,9.
mat | An array containing elements in column-major order. |
stride | The pairwise data stride |
Sets the elements of this transform to those of the given matrix.
The z values are all uniformly ignored. However, it the final element of the matrix is not 1 (e.g. the translation has a w value of 1), then it divides the entire matrix before creating the affine transform
mat | The matrix to convert |
Affine2& cugl::Affine2::set | ( | float | m11, |
float | m12, | ||
float | m21, | ||
float | m22, | ||
float | tx, | ||
float | ty | ||
) |
Sets the individal values of this transform.
m11 | The first element of the first row. |
m12 | The second element of the first row. |
m21 | The first element of the second row. |
m22 | The second element of the second row. |
tx | The translation offset for the x-coordinate. |
ty | The translation offset for the y-coordinate. |
Affine2& cugl::Affine2::setIdentity | ( | ) |
Sets this transform to the identity transform.
Affine2& cugl::Affine2::setZero | ( | ) |
Sets all elements of the current transform to zero.
Subtracts the offset v from m and stores the result in dst.
Subtraction is applied to the offset only; the core matrix is unchanged.
m1 | The initial transform. |
v | The offset to subtract. |
dst | A transform to store the result in. |
|
static |
Subtracts the offset v from m and stores the result in dst.
Subtraction is applied to the offset only; the core matrix is unchanged. Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
m1 | The initial transform in column major order |
v | The offset to subtract. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
Subtracts the specified offset from the current transform.
Subtraction is applied to the offset only; the core matrix is unchanged.
v | The offset to subtract. |
std::string cugl::Affine2::toString | ( | bool | verbose = false | ) | const |
Returns a string representation of this transform for debugging purposes.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
verbose | Whether to include class information |
Transforms the rectangle and stores the result in dst.
This method transforms the four defining points of the rectangle. It then computes the minimal bounding box storing these four points
aff | The affine transform. |
rect | The rect to transform. |
dst | A rect to store the transformed rectangle in. |
Transforms the point and stores the result in dst.
aff | The affine transform. |
point | The point to transform. |
dst | A vector to store the transformed point in. |
|
static |
Transforms the vector array, and stores the result in dst.
The vector is array is treated as a list of 2 element vectors (
aff | The transform matrix. |
input | The array of vectors to transform. |
output | The array to store the transformed vectors. |
size | The size of the two arrays. |
Returns a copy of the given rectangle transformed.
This method transforms the four defining points of the rectangle. It then computes the minimal bounding box storing these four points
Note: This does not modify the original rectangle. To transform a point in place, use the static method.
rect | The rect to transform. |
Returns a copy of the given point transformed.
Note: This does not modify the original point. To transform a point in place, use the static method (or the appropriate operator).
point | The point to transform. |
|
static |
Applies a translation to the given transform and stores the result in dst.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to translate. |
t | The vector storing the individual translation offsets |
dst | A transform to store the result in. |
|
static |
Applies a translation to the given transform and stores the result in dst.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to translate. |
tx | The translation offset for the x-axis. |
ty | The translation offset for the y-axis. |
dst | A transform to store the result in. |
|
static |
Applies a translation to the given transform and stores the result in dst.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to translate in column major order |
t | The vector storing the individual translation offsets |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
|
static |
Applies a translation to the given transform and stores the result in dst.
Both of the float arrays should have at least 6-elements where each of the three pairs have the given stride.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
aff | The transform to translate in column major order |
tx | The translation offset for the x-axis. |
ty | The translation offset for the y-axis. |
dst | A transform to store the result in column major order |
stride | The pairwise data stride |
Applies a translation to this transform.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
t | The vector storing the individual translation offsets |
|
inline |
Applies a translation to this transform.
The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.
tx | The translation offset for the x-axis. |
ty | The translation offset for the y-axis. |
|
static |
The identity transform (ones on the diagonal)
float cugl::Affine2::m[6] |
The condensed affine matrix
|
static |
The transform with all ones
|
static |
The transform with all zeroes