CUGL
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cugl::Affine2 Class Reference

#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 &copy)
 
 ~Affine2 ()
 
Affine2operator= (const Affine2 &mat)
 
Affine2operator= (const float *array)
 
Affine2set (float m11, float m12, float m21, float m22, float tx, float ty)
 
Affine2set (const float *mat)
 
Affine2set (const Affine2 &mat)
 
Affine2setIdentity ()
 
Affine2setZero ()
 
Affine2add (const Vec2 &v)
 
Affine2subtract (const Vec2 &v)
 
Affine2multiply (float scalar)
 
Affine2multiply (const Affine2 &aff)
 
Affine2invert ()
 
Affine2 getInverse () const
 
Affine2operator+= (const Vec2 &v)
 
Affine2operator-= (const Vec2 &v)
 
Affine2operator*= (float scalar)
 
Affine2operator*= (const Affine2 &aff)
 
const Affine2 operator+ (const Vec2 &v) const
 
const Affine2 operator- (const Vec2 &v) const
 
const Affine2 operator* (float scalar) const
 
const Affine2 operator* (const Affine2 &aff) 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
 
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
 
Affine2rotate (float angle)
 
Affine2scale (float value)
 
Affine2scale (const Vec2 &s)
 
Affine2scale (float sx, float sy)
 
Affine2translate (const Vec2 &t)
 
Affine2translate (float tx, float ty)
 
std::string toString (bool verbose=false) const
 
 operator std::string () const
 
 operator Mat4 () const
 
 Affine2 (const Mat4 &mat)
 
Affine2operator= (const Mat4 &mat)
 
Affine2set (const Mat4 &mat)
 

Static Public Member Functions

static Affine2 createScale (float scale)
 
static Affine2createScale (float scale, Affine2 *dst)
 
static Affine2 createScale (float sx, float sy)
 
static Affine2createScale (float sx, float sy, Affine2 *dst)
 
static Affine2 createScale (const Vec2 &scale)
 
static Affine2createScale (const Vec2 &scale, Affine2 *dst)
 
static Affine2 createRotation (float angle)
 
static Affine2createRotation (float angle, Affine2 *dst)
 
static Affine2 createTranslation (const Vec2 &trans)
 
static Affine2createTranslation (const Vec2 &trans, Affine2 *dst)
 
static Affine2 createTranslation (float tx, float ty)
 
static Affine2createTranslation (float tx, float ty, Affine2 *dst)
 
static Affine2add (const Affine2 &m, const Vec2 &v, Affine2 *dst)
 
static Affine2subtract (const Affine2 &m1, const Vec2 &v, Affine2 *dst)
 
static Affine2multiply (const Affine2 &mat, float scalar, Affine2 *dst)
 
static Affine2multiply (const Affine2 &m1, const Affine2 &m2, Affine2 *dst)
 
static Affine2invert (const Affine2 &m1, Affine2 *dst)
 
static Vec2transform (const Affine2 &aff, const Vec2 &point, Vec2 *dst)
 
static Recttransform (const Affine2 &aff, const Rect &rect, Rect *dst)
 
static Affine2rotate (const Affine2 &aff, float angle, Affine2 *dst)
 
static Affine2scale (const Affine2 &aff, float value, Affine2 *dst)
 
static Affine2scale (const Affine2 &aff, const Vec2 &s, Affine2 *dst)
 
static Affine2scale (const Affine2 &aff, float sx, float sy, Affine2 *dst)
 
static Affine2translate (const Affine2 &aff, const Vec2 &t, Affine2 *dst)
 
static Affine2translate (const Affine2 &aff, float tx, float ty, Affine2 *dst)
 
static bool decompose (const Affine2 &mat, Vec2 *scale, float *rot, Vec2 *trans)
 

Public Attributes

float m [4]
 
Vec2 offset
 

Static Public Attributes

static const Affine2 ZERO
 
static const Affine2 ONE
 
static const Affine2 IDENTITY
 

Detailed Description

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.

The affine transform is stored as a 4-element array (containing the core matrix, plus a Vec2 offset. Keeping with the convention of Mat4, the core matrix is stored in column-order format. In addition, we assume that all operations are multiplied on the right.

Constructor & Destructor Documentation

cugl::Affine2::Affine2 ( )

Creates the identity transform.

1  0
0  1 + (0,0)
cugl::Affine2::Affine2 ( float  m11,
float  m12,
float  m21,
float  m22,
float  tx,
float  ty 
)

Constructs a matrix initialized to the specified values.

Parameters
m11The first element of the first row.
m12The second element of the first row.
m21The first element of the second row.
m22The second element of the second row.
txThe translation offset for the x-coordinate.
tyThe 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 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
1   3 + (4,5)
Parameters
matAn 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.

Parameters
copyThe transform to copy.
cugl::Affine2::~Affine2 ( )
inline

Destroys this transform, releasing all resources.

cugl::Affine2::Affine2 ( const Mat4 mat)
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

Parameters
matThe matrix to convert

Member Function Documentation

static Affine2* cugl::Affine2::add ( const Affine2 m,
const Vec2 v,
Affine2 dst 
)
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.

Parameters
mThe initial transform.
vThe offset to add.
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::add ( const Vec2 v)
inline

Adds the specified offset to this transform.

Addition is applied to the offset only; the core matrix is unchanged.

Parameters
vThe offset to add.
Returns
A reference to the Affine2 after addition.
static Affine2 cugl::Affine2::createRotation ( float  angle)
inlinestatic

Returns a rotation transform for the given angle.

The angle measurement is in radians. The rotation is counter clockwise about the z-axis.

Parameters
angleThe angle (in radians).
Returns
a rotation transform for the given angle.
static Affine2* cugl::Affine2::createRotation ( float  angle,
Affine2 dst 
)
static

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.

Parameters
angleThe angle (in radians).
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2 cugl::Affine2::createScale ( float  scale)
inlinestatic

Returns a uniform scale transform.

Parameters
scaleThe amount to scale.
Returns
a uniform scale transform.
static Affine2* cugl::Affine2::createScale ( float  scale,
Affine2 dst 
)
static

Creates a uniform scale transform, putting it in dst.

Parameters
scaleThe amount to scale.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2 cugl::Affine2::createScale ( float  sx,
float  sy 
)
inlinestatic

Returns a nonuniform scale transform.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
Returns
a nonuniform scale transform.
static Affine2* cugl::Affine2::createScale ( float  sx,
float  sy,
Affine2 dst 
)
static

Creates a nonuniform scale transform, putting it in dst.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2 cugl::Affine2::createScale ( const Vec2 scale)
inlinestatic

Returns a nonuniform scale transform from the given vector.

Parameters
scaleThe nonuniform scale value.
Returns
a nonuniform scale transform from the given vector.
static Affine2* cugl::Affine2::createScale ( const Vec2 scale,
Affine2 dst 
)
static

Creates a nonuniform scale transform from the given vector, putting it in dst.

Parameters
scaleThe nonuniform scale value.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2 cugl::Affine2::createTranslation ( const Vec2 trans)
inlinestatic

Returns a translation transform from the given offset

Parameters
transThe translation offset.
Returns
a translation transform from the given offset
static Affine2* cugl::Affine2::createTranslation ( const Vec2 trans,
Affine2 dst 
)
static

Creates a translation transform from the given offset, putting it in dst.

Parameters
transThe translation offset.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2 cugl::Affine2::createTranslation ( float  tx,
float  ty 
)
inlinestatic

Returns a translation transform from the given parameters.

Parameters
txThe translation on the x-axis.
tyThe translation on the y-axis.
Returns
a translation transform from the given parameters.
static Affine2* cugl::Affine2::createTranslation ( float  tx,
float  ty,
Affine2 dst 
)
static

Creates a translation transform from the given parameters, putting it in dst.

Parameters
txThe translation on the x-axis.
tyThe translation on the y-axis.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static bool cugl::Affine2::decompose ( const Affine2 mat,
Vec2 scale,
float *  rot,
Vec2 trans 
)
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 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.

Parameters
matThe transform to decompose.
scaleThe scale component.
rotThe rotation component.
transThe translation component.
Returns
true if all requested components were properly extracted
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.

Parameters
matThe transform to compare against.
varianceThe comparison tolerance.
Returns
true if the transforms are within tolerance of each other.
float cugl::Affine2::getDeterminant ( ) const
inline

Returns the determinant of this transform.

The determinant is a feature of the core matrix. The offset is ignored.

Returns
the determinant of this transform.
Affine2 cugl::Affine2::getInverse ( ) const
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.

Returns
a copy of the inverse of this transform.
float cugl::Affine2::getRotation ( ) const
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. (

Returns
the rotational angle of this transform.
Vec2 cugl::Affine2::getScale ( ) const
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.

To work properly, the transform must have been constructed in the following order: scale, then rotate, then translation. In any other order, the scale is not guaranteed to be correct.

Returns
the scale component of this transform.
Vec2 cugl::Affine2::getTranslation ( ) const
inline

Returns the translational component of this transform.

To work properly, the transform must have been constructed in the following order: scale, then rotate, then translation. In any other order, the translation is not guaranteed to be correct.

Returns
the translational component of this transform.
static Affine2* cugl::Affine2::invert ( const Affine2 m1,
Affine2 dst 
)
static

Inverts m1 and stores the result in dst.

If the transform cannot be inverted, this method stores the zero transform in dst.

Parameters
m1The transform to negate.
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::invert ( )
inline

Inverts this transform in place.

If the transform cannot be inverted, this method sets it to the zero transform.

Returns
A reference to the Affine2 after the inversion.
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.

Parameters
affThe transform to compare against.
Returns
true if the transforms are exactly equal to each other.
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.

Parameters
varianceThe comparison tolerance
Returns
true if this transform is equal to the identity transform.
bool cugl::Affine2::isInvertible ( float  variance = CU_MATH_EPSILON) const
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.

Returns
true if this transform is invertible.
static Affine2* cugl::Affine2::multiply ( const Affine2 mat,
float  scalar,
Affine2 dst 
)
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.

Parameters
matThe transform.
scalarThe scalar value.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2* cugl::Affine2::multiply ( const Affine2 m1,
const Affine2 m2,
Affine2 dst 
)
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.

Parameters
m1The first transform to multiply.
m2The second transform to multiply.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::multiply ( float  scalar)
inline

Multiplies the components of this transform by the specified scalar.

The scalar is applied to BOTH the core matrix and the offset.

Parameters
scalarThe scalar value.
Returns
A reference to the Affine2 after multiplication.
Affine2& cugl::Affine2::multiply ( const Affine2 aff)
inline

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.

Parameters
affThe transform to multiply.
Returns
A reference to the Affine2 after multiplication.
cugl::Affine2::operator Mat4 ( ) const

Cast from Affine2 to a Mat4.

cugl::Affine2::operator std::string ( ) const
inline

Cast from Vec4 to a string.

bool cugl::Affine2::operator!= ( const Affine2 aff) const
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.

Parameters
affThe transform to compare against.
Returns
true if this transform is not equal to the given transform.
const Affine2 cugl::Affine2::operator* ( float  scalar) const
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.

Parameters
scalarThe scalar value.
Returns
the product of this transform with the given scalar.
const Affine2 cugl::Affine2::operator* ( const Affine2 aff) const
inline

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.

Parameters
affThe transform to multiply by.
Returns
the matrix product of this matrix with the given matrix.
Affine2& cugl::Affine2::operator*= ( float  scalar)
inline

Multiplies the components of this transform by the specified scalar.

The scalar is applied to BOTH the core matrix and the offset.

Parameters
scalarThe scalar value.
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::operator*= ( const Affine2 aff)
inline

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.

Parameters
affThe transform to multiply by.
Returns
A reference to this (modified) Affine2 for chaining.
const Affine2 cugl::Affine2::operator+ ( const Vec2 v) const
inline

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.

Parameters
vThe offset to add.
Returns
the sum of this transform with the given offset.
Affine2& cugl::Affine2::operator+= ( const Vec2 v)
inline

Adds the given offset to this transform in place.

Addition is applied to the offset only; the core matrix is unchanged.

Parameters
vThe offset to add
Returns
A reference to this (modified) Affine2 for chaining.
const Affine2 cugl::Affine2::operator- ( const Vec2 v) const
inline

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.

Parameters
vThe offset to subtract.
Returns
the difference of this transform and the given offset.
Affine2& cugl::Affine2::operator-= ( const Vec2 v)
inline

Subtracts the given offset from this transform in place.

Subtraction is applied to the offset only; the core matrix is unchanged.

Parameters
vThe offset to subtract
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::operator= ( const Affine2 mat)
inline

Sets the elements of this transform to those in the specified transform.

Parameters
matThe transform to copy.
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::operator= ( const float *  array)
inline

Sets the values of this transform to those in the specified column-major array.

The passed-in array is 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
1   3 + (4,5)
Parameters
arrayAn array containing 6 elements in column-major order.
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::operator= ( const Mat4 mat)

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

Parameters
matThe matrix to convert
Returns
A reference to this (modified) Affine2 for chaining.
bool cugl::Affine2::operator== ( const Affine2 aff) const
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.

Parameters
affThe transform to compare against.
Returns
true if this transform is equal to the given transform.
static Affine2* cugl::Affine2::rotate ( const Affine2 aff,
float  angle,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to rotate.
angleThe angle (in radians).
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::rotate ( float  angle)
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.

Parameters
angleThe angle (in radians).
Returns
This transform, after rotation.
static Affine2* cugl::Affine2::scale ( const Affine2 aff,
float  value,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to scale.
valueThe scalar to multiply by.
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2* cugl::Affine2::scale ( const Affine2 aff,
const Vec2 s,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to scale.
sThe vector storing the individual scaling factors
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2* cugl::Affine2::scale ( const Affine2 aff,
float  sx,
float  sy,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to scale.
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::scale ( float  value)
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.

Parameters
valueThe scalar to multiply by.
Returns
This transform, after scaling.
Affine2& cugl::Affine2::scale ( const Vec2 s)
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.

Parameters
sThe vector storing the individual scaling factors
Returns
This transform, after scaling.
Affine2& cugl::Affine2::scale ( float  sx,
float  sy 
)
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.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
Returns
This transform, after scaling.
Affine2& cugl::Affine2::set ( float  m11,
float  m12,
float  m21,
float  m22,
float  tx,
float  ty 
)

Sets the individal values of this transform.

Parameters
m11The first element of the first row.
m12The second element of the first row.
m21The first element of the second row.
m22The second element of the second row.
txThe translation offset for the x-coordinate.
tyThe translation offset for the y-coordinate.
Returns
A reference to this (modified) Affine2 for chaining.
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 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
1   3 + (4,5)
Parameters
matAn array containing 6 elements in column-major order.
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::set ( const Affine2 mat)

Sets the elements of this transform to those in the specified transform.

Parameters
matThe transform to copy.
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::set ( const Mat4 mat)

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

Parameters
matThe matrix to convert
Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::setIdentity ( )

Sets this transform to the identity transform.

Returns
A reference to this (modified) Affine2 for chaining.
Affine2& cugl::Affine2::setZero ( )

Sets all elements of the current transform to zero.

Returns
A reference to this (modified) Affine2 for chaining.
static Affine2* cugl::Affine2::subtract ( const Affine2 m1,
const Vec2 v,
Affine2 dst 
)
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.

Parameters
m1The initial transform.
vThe offset to subtract.
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::subtract ( const Vec2 v)
inline

Subtracts the specified offset from the current transform.

Subtraction is applied to the offset only; the core matrix is unchanged.

Parameters
vThe offset to subtract.
Returns
A reference to the Affine2 after subtraction.
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.

Parameters
verboseWhether to include class information
Returns
a string representation of this transform for debugging purposes.
static Vec2* cugl::Affine2::transform ( const Affine2 aff,
const Vec2 point,
Vec2 dst 
)
static

Transforms the point and stores the result in dst.

Parameters
affThe affine transform.
pointThe point to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
static Rect* cugl::Affine2::transform ( const Affine2 aff,
const Rect rect,
Rect dst 
)
static

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

Parameters
affThe affine transform.
rectThe rect to transform.
dstA rect to store the transformed rectangle in.
Returns
A reference to dst for chaining
Vec2 cugl::Affine2::transform ( const Vec2 point) const
inline

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).

Parameters
pointThe point to transform.
Returns
a copy of this point transformed.
Rect cugl::Affine2::transform ( const Rect rect) const

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.

Parameters
rectThe rect to transform.
Returns
A reference to dst for chaining
static Affine2* cugl::Affine2::translate ( const Affine2 aff,
const Vec2 t,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to translate.
tThe vector storing the individual translation offsets
dstA transform to store the result in.
Returns
A reference to dst for chaining
static Affine2* cugl::Affine2::translate ( const Affine2 aff,
float  tx,
float  ty,
Affine2 dst 
)
inlinestatic

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.

Parameters
affThe transform to translate.
txThe translation offset for the x-axis.
tyThe translation offset for the y-axis.
dstA transform to store the result in.
Returns
A reference to dst for chaining
Affine2& cugl::Affine2::translate ( const Vec2 t)
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.

Parameters
tThe vector storing the individual translation offsets
Returns
This transform, after translation.
Affine2& cugl::Affine2::translate ( float  tx,
float  ty 
)
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.

Parameters
txThe translation offset for the x-axis.
tyThe translation offset for the y-axis.
Returns
This transform, after translation.

Member Data Documentation

const Affine2 cugl::Affine2::IDENTITY
static

The identity transform (ones on the diagonal)

float cugl::Affine2::m[4]

The core matrix

Vec2 cugl::Affine2::offset

The translation offset

const Affine2 cugl::Affine2::ONE
static

The transform with all ones

const Affine2 cugl::Affine2::ZERO
static

The transform with all zeroes


The documentation for this class was generated from the following file: