Loading...
Searching...
No Matches
juce::AffineTransform Class Referencefinal

## Detailed Description

Represents a 2D affine-transformation matrix.

An affine transformation is a transformation such as a rotation, scale, shear, resize or translation.

These are used for various 2D transformation tasks, e.g. with Path objects.

See also
  Path, Point, Line

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

- juce_graphics/geometry/juce_AffineTransform.h

## Public Member Functions

| AffineTransform ()=default
| Creates an identity transform.
| AffineTransform (const AffineTransform &)=default
| Creates a copy of another transform.
| AffineTransform (float mat00, float mat01, float mat02, float mat10, float mat11, float mat12) noexcept
| Creates a transform from a set of raw matrix values.
AffineTransform & | operator= (const AffineTransform &)=default
| Copies from another AffineTransform object.
bool | operator== (const AffineTransform &other) const noexcept
| Compares two transforms.
bool | operator!= (const AffineTransform &other) const noexcept
| Compares two transforms.
template<typename ValueType>
void | transformPoint (ValueType &x, ValueType &y) const noexcept
| Transforms a 2D coordinate using this matrix.
template<typename ValueType>
void | transformPoints (ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2) const noexcept
| Transforms two 2D coordinates using this matrix.
template<typename ValueType>
void | transformPoints (ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2, ValueType &x3, ValueType &y3) const noexcept
| Transforms three 2D coordinates using this matrix.
AffineTransform | translated (float deltaX, float deltaY) const noexcept
| Returns a new transform which is the same as this one followed by a translation.
template<typename PointType>
AffineTransform | translated (PointType delta) const noexcept
| Returns a new transform which is the same as this one followed by a translation.
AffineTransform | withAbsoluteTranslation (float translationX, float translationY) const noexcept
| Returns a copy of this transform with the specified translation matrix values.
AffineTransform | rotated (float angleInRadians) const noexcept
| Returns a transform which is the same as this one followed by a rotation.
AffineTransform | rotated (float angleInRadians, float pivotX, float pivotY) const noexcept
| Returns a transform which is the same as this one followed by a rotation about a given point.
AffineTransform | scaled (float factorX, float factorY) const noexcept
| Returns a transform which is the same as this one followed by a re-scaling.
AffineTransform | scaled (float factor) const noexcept
| Returns a transform which is the same as this one followed by a re-scaling.
AffineTransform | scaled (float factorX, float factorY, float pivotX, float pivotY) const noexcept
| Returns a transform which is the same as this one followed by a re-scaling.
AffineTransform | sheared (float shearX, float shearY) const noexcept
| Returns a transform which is the same as this one followed by a shear.
AffineTransform | inverted () const noexcept
| Returns a matrix which is the inverse operation of this one.
AffineTransform | followedBy (const AffineTransform &other) const noexcept
| Returns the result of concatenating another transformation after this one.
bool | isIdentity () const noexcept
| Returns true if this transform has no effect on points.
bool | isSingularity () const noexcept
| Returns true if this transform maps to a singularity (i.e., has no inverse).
bool | isOnlyTranslation () const noexcept
| Returns true if the transform only translates, and doesn't scale or rotate the points.
bool | isOnlyTranslationOrScale () const noexcept
| Returns true if the transform only translates and/or scales.
float | getTranslationX () const noexcept
| If this transform is only a translation, this returns the X offset.
float | getTranslationY () const noexcept
| If this transform is only a translation, this returns the X offset.
float | getDeterminant () const noexcept
| Returns the determinant of the transform.

## Static Public Member Functions

static AffineTransform | translation (float deltaX, float deltaY) noexcept
| Returns a new transform which is a translation.
template<typename PointType>
static AffineTransform | translation (PointType delta) noexcept
| Returns a new transform which is a translation.
static AffineTransform | rotation (float angleInRadians) noexcept
| Returns a new transform which is a rotation about (0, 0).
static AffineTransform | rotation (float angleInRadians, float pivotX, float pivotY) noexcept
| Returns a new transform which is a rotation about a given point.
static AffineTransform | scale (float factorX, float factorY) noexcept
| Returns a new transform which is a re-scale about the origin.
static AffineTransform | scale (float factor) noexcept
| Returns a new transform which is a re-scale about the origin.
static AffineTransform | scale (float factorX, float factorY, float pivotX, float pivotY) noexcept
| Returns a new transform which is a re-scale centred around the point provided.
static AffineTransform | shear (float shearX, float shearY) noexcept
| Returns a shear transform, centred around the origin (0, 0).
static AffineTransform | verticalFlip (float height) noexcept
| Returns a transform that will flip coordinates vertically within a window of the given height.
static AffineTransform | horizontalFlip (float width) noexcept
| Returns a transform that will flip coordinates horizontally within a window of the given width.
static AffineTransform | fromTargetPoints (float x00, float y00, float x10, float y10, float x01, float y01) noexcept
| Returns the transform that will map three known points onto three coordinates that are supplied.
static AffineTransform | fromTargetPoints (float sourceX1, float sourceY1, float targetX1, float targetY1, float sourceX2, float sourceY2, float targetX2, float targetY2, float sourceX3, float sourceY3, float targetX3, float targetY3) noexcept
| Returns the transform that will map three specified points onto three target points.
template<typename PointType>
static AffineTransform | fromTargetPoints (PointType source1, PointType target1, PointType source2, PointType target2, PointType source3, PointType target3) noexcept
| Returns the transform that will map three specified points onto three target points.

## Public Attributes

float | mat00 { 1.0f }
float | mat01 { 0.0f }
float | mat02 { 0.0f }
float | mat10 { 0.0f }
float | mat11 { 1.0f }
float | mat12 { 0.0f }

## Constructors and Destructors

## AffineTransform() [1/3]

juce::AffineTransform::AffineTransform | ( |  | ) |

default

Creates an identity transform.

Referenced by AffineTransform(), followedBy(), fromTargetPoints(), fromTargetPoints(), fromTargetPoints(), getDeterminant(), horizontalFlip(), inverted(), operator!=(), operator=(), operator==(), rotated(), rotated(), rotation(), rotation(), scale(), scale(), scale(), scaled(), scaled(), scaled(), shear(), sheared(), translated(), translated(), translation(), translation(), verticalFlip(), and withAbsoluteTranslation().

## AffineTransform() [2/3]

juce::AffineTransform::AffineTransform | ( | const AffineTransform & |  | ) |

default

Creates a copy of another transform.

References AffineTransform().

## AffineTransform() [3/3]

juce::AffineTransform::AffineTransform | ( | float | mat00,
|  | float | mat01,
|  | float | mat02,
|  | float | mat10,
|  | float | mat11,
|  | float | mat12 )

noexcept

Creates a transform from a set of raw matrix values.

The resulting matrix is:

    (mat00 mat01 mat02)
    (mat10 mat11 mat12)
    (  0     0     1  )

References mat00, mat01, mat02, mat10, mat11, and mat12.

## Member Functions

## operator=()

AffineTransform & juce::AffineTransform::operator= | ( | const AffineTransform & |  | ) |

default

Copies from another AffineTransform object.

References AffineTransform().

## operator==()

bool juce::AffineTransform::operator== | ( | const AffineTransform & | other | ) | const

noexcept

Compares two transforms.

References AffineTransform().

## operator!=()

bool juce::AffineTransform::operator!= | ( | const AffineTransform & | other | ) | const

noexcept

Compares two transforms.

References AffineTransform().

## transformPoint()

template<typename ValueType>

void juce::AffineTransform::transformPoint | ( | ValueType & | x,
|  | ValueType & | y ) const

inline noexcept

Transforms a 2D coordinate using this matrix.

References mat00, mat01, mat02, mat10, mat11, mat12, x, and y.

## transformPoints() [1/2]

template<typename ValueType>

void juce::AffineTransform::transformPoints | ( | ValueType & | x1,
|  | ValueType & | y1,
|  | ValueType & | x2,
|  | ValueType & | y2 ) const

inline noexcept

Transforms two 2D coordinates using this matrix.

This is just a shortcut for calling transformPoint() on each of these pairs of coordinates in turn. (And putting all the calculations into one function hopefully also gives the compiler a bit more scope for pipelining it).

References mat00, mat01, mat02, mat10, mat11, and mat12.

## transformPoints() [2/2]

template<typename ValueType>

void juce::AffineTransform::transformPoints | ( | ValueType & | x1,
|  | ValueType & | y1,
|  | ValueType & | x2,
|  | ValueType & | y2,
|  | ValueType & | x3,
|  | ValueType & | y3 ) const

inline noexcept

Transforms three 2D coordinates using this matrix.

This is just a shortcut for calling transformPoint() on each of these pairs of coordinates in turn. (And putting all the calculations into one function hopefully also gives the compiler a bit more scope for pipelining it).

References mat00, mat01, mat02, mat10, mat11, and mat12.

## translated() [1/2]

AffineTransform juce::AffineTransform::translated | ( | float | deltaX,
|  | float | deltaY ) const

noexcept

Returns a new transform which is the same as this one followed by a translation.

References AffineTransform().

Referenced by translated().

## translated() [2/2]

template<typename PointType>

AffineTransform juce::AffineTransform::translated | ( | PointType | delta | ) | const

inline noexcept

Returns a new transform which is the same as this one followed by a translation.

References AffineTransform(), and translated().

## translation() [1/2]

AffineTransform juce::AffineTransform::translation | ( | float | deltaX,
|  | float | deltaY )

static noexcept

Returns a new transform which is a translation.

References AffineTransform().

Referenced by translation().

## translation() [2/2]

template<typename PointType>

AffineTransform juce::AffineTransform::translation | ( | PointType | delta | ) |

inline static noexcept

Returns a new transform which is a translation.

References AffineTransform(), and translation().

## withAbsoluteTranslation()

AffineTransform juce::AffineTransform::withAbsoluteTranslation | ( | float | translationX,
|  | float | translationY ) const

noexcept

Returns a copy of this transform with the specified translation matrix values.

References AffineTransform().

## rotated() [1/2]

AffineTransform juce::AffineTransform::rotated | ( | float | angleInRadians | ) | const

noexcept

Returns a transform which is the same as this one followed by a rotation.

The rotation is specified by a number of radians to rotate clockwise, centred around the origin (0, 0).

References AffineTransform().

## rotated() [2/2]

AffineTransform juce::AffineTransform::rotated | ( | float | angleInRadians,
|  | float | pivotX,
|  | float | pivotY ) const

noexcept

Returns a transform which is the same as this one followed by a rotation about a given point.

The rotation is specified by a number of radians to rotate clockwise, centred around the coordinates passed in.

References AffineTransform().

## rotation() [1/2]

AffineTransform juce::AffineTransform::rotation | ( | float | angleInRadians | ) |

static noexcept

Returns a new transform which is a rotation about (0, 0).

References AffineTransform().

## rotation() [2/2]

AffineTransform juce::AffineTransform::rotation | ( | float | angleInRadians,
|  | float | pivotX,
|  | float | pivotY )

static noexcept

Returns a new transform which is a rotation about a given point.

References AffineTransform().

## scaled() [1/3]

AffineTransform juce::AffineTransform::scaled | ( | float | factorX,
|  | float | factorY ) const

noexcept

Returns a transform which is the same as this one followed by a re-scaling.

The scaling is centred around the origin (0, 0).

References AffineTransform().

## scaled() [2/3]

AffineTransform juce::AffineTransform::scaled | ( | float | factor | ) | const

noexcept

Returns a transform which is the same as this one followed by a re-scaling.

The scaling is centred around the origin (0, 0).

References AffineTransform().

## scaled() [3/3]

AffineTransform juce::AffineTransform::scaled | ( | float | factorX,
|  | float | factorY,
|  | float | pivotX,
|  | float | pivotY ) const

noexcept

Returns a transform which is the same as this one followed by a re-scaling.

The scaling is centred around the origin provided.

References AffineTransform().

## scale() [1/3]

AffineTransform juce::AffineTransform::scale | ( | float | factorX,
|  | float | factorY )

static noexcept

Returns a new transform which is a re-scale about the origin.

References AffineTransform().

## scale() [2/3]

AffineTransform juce::AffineTransform::scale | ( | float | factor | ) |

static noexcept

Returns a new transform which is a re-scale about the origin.

References AffineTransform().

## scale() [3/3]

AffineTransform juce::AffineTransform::scale | ( | float | factorX,
|  | float | factorY,
|  | float | pivotX,
|  | float | pivotY )

static noexcept

Returns a new transform which is a re-scale centred around the point provided.

References AffineTransform().

## sheared()

AffineTransform juce::AffineTransform::sheared | ( | float | shearX,
|  | float | shearY ) const

noexcept

Returns a transform which is the same as this one followed by a shear.

The shear is centred around the origin (0, 0).

References AffineTransform().

## shear()

AffineTransform juce::AffineTransform::shear | ( | float | shearX,
|  | float | shearY )

static noexcept

Returns a shear transform, centred around the origin (0, 0).

References AffineTransform().

## verticalFlip()

AffineTransform juce::AffineTransform::verticalFlip | ( | float | height | ) |

static noexcept

Returns a transform that will flip coordinates vertically within a window of the given height.

This is handy for converting between upside-down coordinate systems such as OpenGL or CoreGraphics.

References AffineTransform().

## horizontalFlip()

AffineTransform juce::AffineTransform::horizontalFlip | ( | float | width | ) |

static noexcept

Returns a transform that will flip coordinates horizontally within a window of the given width.

References AffineTransform().

## inverted()

AffineTransform juce::AffineTransform::inverted | ( |  | ) | const

noexcept

Returns a matrix which is the inverse operation of this one.

Some matrices don't have an inverse - in this case, the method will just return an identity transform.

References AffineTransform().

## fromTargetPoints() [1/3]

AffineTransform juce::AffineTransform::fromTargetPoints | ( | float | x00,
|  | float | y00,
|  | float | x10,
|  | float | y10,
|  | float | x01,
|  | float | y01 )

static noexcept

Returns the transform that will map three known points onto three coordinates that are supplied.

This returns the transform that will transform (0, 0) into (x00, y00), (1, 0) to (x10, y10), and (0, 1) to (x01, y01).

References AffineTransform(), and fromTargetPoints().

Referenced by fromTargetPoints(), fromTargetPoints(), and fromTargetPoints().

## fromTargetPoints() [2/3]

AffineTransform juce::AffineTransform::fromTargetPoints | ( | float | sourceX1,
|  | float | sourceY1,
|  | float | targetX1,
|  | float | targetY1,
|  | float | sourceX2,
|  | float | sourceY2,
|  | float | targetX2,
|  | float | targetY2,
|  | float | sourceX3,
|  | float | sourceY3,
|  | float | targetX3,
|  | float | targetY3 )

static noexcept

Returns the transform that will map three specified points onto three target points.

References AffineTransform(), and fromTargetPoints().

## fromTargetPoints() [3/3]

template<typename PointType>

AffineTransform juce::AffineTransform::fromTargetPoints | ( | PointType | source1,
|  | PointType | target1,
|  | PointType | source2,
|  | PointType | target2,
|  | PointType | source3,
|  | PointType | target3 )

inline static noexcept

Returns the transform that will map three specified points onto three target points.

References AffineTransform(), and fromTargetPoints().

## followedBy()

AffineTransform juce::AffineTransform::followedBy | ( | const AffineTransform & | other | ) | const

noexcept

Returns the result of concatenating another transformation after this one.

References AffineTransform().

## isIdentity()

bool juce::AffineTransform::isIdentity | ( |  | ) | const

noexcept

Returns true if this transform has no effect on points.

## isSingularity()

bool juce::AffineTransform::isSingularity | ( |  | ) | const

noexcept

Returns true if this transform maps to a singularity (i.e., has no inverse).

References isSingularity().

Referenced by isSingularity().

## isOnlyTranslation()

bool juce::AffineTransform::isOnlyTranslation | ( |  | ) | const

noexcept

Returns true if the transform only translates, and doesn't scale or rotate the points.

References isOnlyTranslation().

Referenced by isOnlyTranslation().

## isOnlyTranslationOrScale()

bool juce::AffineTransform::isOnlyTranslationOrScale | ( |  | ) | const

noexcept

Returns true if the transform only translates and/or scales.

References isOnlyTranslationOrScale().

Referenced by isOnlyTranslationOrScale().

## getTranslationX()

float juce::AffineTransform::getTranslationX | ( |  | ) | const

inline noexcept

If this transform is only a translation, this returns the X offset.

See also
  isOnlyTranslation

References getTranslationX(), and mat02.

Referenced by getTranslationX().

## getTranslationY()

float juce::AffineTransform::getTranslationY | ( |  | ) | const

inline noexcept

If this transform is only a translation, this returns the X offset.

See also
  isOnlyTranslation

References mat12.

## getDeterminant()

float juce::AffineTransform::getDeterminant | ( |  | ) | const

noexcept

Returns the determinant of the transform.

References AffineTransform().

## Member Data Documentation

## mat00

float juce::AffineTransform::mat00 { 1.0f }

Referenced by AffineTransform(), transformPoint(), transformPoints(), and transformPoints().

## mat01

float juce::AffineTransform::mat01 { 0.0f }

Referenced by AffineTransform(), transformPoint(), transformPoints(), and transformPoints().

## mat02

float juce::AffineTransform::mat02 { 0.0f }

Referenced by AffineTransform(), getTranslationX(), transformPoint(), transformPoints(), and transformPoints().

## mat10

float juce::AffineTransform::mat10 { 0.0f }

Referenced by AffineTransform(), transformPoint(), transformPoints(), and transformPoints().

## mat11

float juce::AffineTransform::mat11 { 1.0f }

Referenced by AffineTransform(), transformPoint(), transformPoints(), and transformPoints().

## mat12

float juce::AffineTransform::mat12 { 0.0f }

Referenced by AffineTransform(), getTranslationY(), transformPoint(), transformPoints(), and transformPoints().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited