MutableAffineTransform


public final class MutableAffineTransform extends AffineTransform


A mutable affine transformation in the plane. Individual operations can be populated with methods like populateFromTranslation and populateFromRotationDegrees.

See AffineTransform for more general documentation about how these transforms are represented. See ImmutableAffineTransform for an immutable alternative to this class.

Summary

Public constructors

Constructs an identity MutableAffineTransform:

Public methods

boolean
equals(Object other)

Component-wise equality operator for MutableAffineTransform.

int
final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with the same values contained in input.

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with an identity transformation, which maps a point to itself, i.e. it leaves it unchanged.

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with a transformation that rotates degrees in the direction from the positive x-axis towards the positive y-axis.

final @NonNull MutableAffineTransform
populateFromScale(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in both the x and y direction by the given scaleFactor, centered about the origin.

final @NonNull MutableAffineTransform
populateFromScale(float xScaleFactor, float yScaleFactor)

Fills this MutableAffineTransform with a transformation that scales in both the x- and y-direction by the given pair of factors; xScaleFactor and yScaleFactor respectively, centered about the origin.

final @NonNull MutableAffineTransform
populateFromScaleX(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in the x-direction by the given factor, centered about the origin.

final @NonNull MutableAffineTransform
populateFromScaleY(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in the y-direction by the given factor, centered about the origin.

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with a transformation that skews in the x-direction by the given factor.

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with a transformation that skews in the y-direction by the given factor.

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with a transformation that translates by the given offset vector.

final void
setValues(@Size(min = 6) @NonNull float[] values)

Like setValues, but accepts a FloatArray instead of individual float values.

final void
setValues(float m00, float m10, float m20, float m01, float m11, float m21)

Populates this transform with the given values, starting with the top left corner of the matrix and proceeding in row-major order.

@NonNull String

Extension functions

final @NonNull MutableAffineTransform

Fills this MutableAffineTransform with the values from matrix.

Inherited methods

From androidx.ink.geometry.AffineTransform
final @NonNull ImmutableParallelogram

Returns an ImmutableParallelogram containing the result of applying the AffineTransform to box.

final @NonNull ImmutableParallelogram

Returns an ImmutableParallelogram containing the result of applying the AffineTransform to parallelogram.

final @NonNull ImmutableVec

Returns an ImmutableVec containing the result of applying the AffineTransform to point.

final @NonNull ImmutableSegment

Returns an ImmutableSegment containing the result of applying the AffineTransform to segment.

final @NonNull ImmutableTriangle

Returns an ImmutableTriangle containing the result of applying the AffineTransform to triangle.

final @NonNull MutableParallelogram
applyTransform(
    @NonNull Box box,
    @NonNull MutableParallelogram outParallelogram
)

Apply the AffineTransform to the Box and store the result in the MutableParallelogram.

final @NonNull MutableParallelogram
applyTransform(
    @NonNull Parallelogram parallelogram,
    @NonNull MutableParallelogram outParallelogram
)

Apply the AffineTransform to the Parallelogram and store the result in the MutableParallelogram.

final @NonNull MutableVec

Apply the AffineTransform to the Vec and store the result in the MutableVec.

final @NonNull MutableSegment
applyTransform(
    @NonNull Segment segment,
    @NonNull MutableSegment outSegment
)

Apply the AffineTransform to the Segment and store the result in the MutableSegment.

final @NonNull MutableTriangle
applyTransform(
    @NonNull Triangle triangle,
    @NonNull MutableTriangle outTriangle
)

Apply the AffineTransform to the Triangle and store the result in the MutableTriangle.

final @NonNull ImmutableAffineTransform

Returns the inverse of the AffineTransform.

final @NonNull MutableAffineTransform

Populates outAffineTransform with the inverse of this AffineTransform.

final @Size(min = 6) @NonNull float[]
getValues(@Size(min = 6) @NonNull float[] outArray)

Populates the first 6 elements of outArray with the values of this transform, starting with the top left corner of the matrix and proceeding in row-major order.

final boolean
isAlmostEqual(
    @NonNull AffineTransform other,
    @FloatRange(from = 0.0) float tolerance
)

Compares this AffineTransform with other, and returns true if each component of the transform matrix is within tolerance of the corresponding component of other.

Public constructors

MutableAffineTransform

Added in 1.0.0-alpha07
public MutableAffineTransform()

Constructs an identity MutableAffineTransform:

⎡1  0  0⎤
⎢0 1 0⎥
⎣0 0 1⎦

This is useful when pre-allocating a scratch instance to be filled later.

Public methods

equals

public boolean equals(Object other)

Component-wise equality operator for MutableAffineTransform.

Due to the propagation floating point precision errors, operations that may be equivalent over the real numbers are not always equivalent for floats, and might return false for equals in some cases.

hashCode

public int hashCode()

populateFrom

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFrom(@NonNull AffineTransform input)

Fills this MutableAffineTransform with the same values contained in input.

Returns the modified instance to allow chaining calls.

populateFromIdentity

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromIdentity()

Fills this MutableAffineTransform with an identity transformation, which maps a point to itself, i.e. it leaves it unchanged.

Returns the modified instance to allow chaining calls.

populateFromRotationDegrees

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromRotationDegrees(@AngleDegreesFloat float degrees)

Fills this MutableAffineTransform with a transformation that rotates degrees in the direction from the positive x-axis towards the positive y-axis.

Returns the modified instance to allow chaining calls.

populateFromScale

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromScale(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in both the x and y direction by the given scaleFactor, centered about the origin.

Returns the modified instance to allow chaining calls.

populateFromScale

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromScale(float xScaleFactor, float yScaleFactor)

Fills this MutableAffineTransform with a transformation that scales in both the x- and y-direction by the given pair of factors; xScaleFactor and yScaleFactor respectively, centered about the origin.

Returns the modified instance to allow chaining calls.

populateFromScaleX

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromScaleX(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in the x-direction by the given factor, centered about the origin.

Returns the modified instance to allow chaining calls.

populateFromScaleY

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromScaleY(float scaleFactor)

Fills this MutableAffineTransform with a transformation that scales in the y-direction by the given factor, centered about the origin.

Returns the modified instance to allow chaining calls.

populateFromSkewX

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromSkewX(float sx)

Fills this MutableAffineTransform with a transformation that skews in the x-direction by the given factor.

Returns the modified instance to allow chaining calls.

populateFromSkewY

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromSkewY(float sy)

Fills this MutableAffineTransform with a transformation that skews in the y-direction by the given factor.

Returns the modified instance to allow chaining calls.

populateFromTranslation

Added in 1.0.0-alpha07
public final @NonNull MutableAffineTransform populateFromTranslation(@NonNull Vec offset)

Fills this MutableAffineTransform with a transformation that translates by the given offset vector.

Returns the modified instance to allow chaining calls.

setValues

Added in 1.0.0-alpha07
public final void setValues(@Size(min = 6) @NonNull float[] values)

Like setValues, but accepts a FloatArray instead of individual float values.

setValues

Added in 1.0.0-alpha07
public final void setValues(float m00, float m10, float m20, float m01, float m11, float m21)

Populates this transform with the given values, starting with the top left corner of the matrix and proceeding in row-major order.

Prefer to modify this object with functions that apply specific transform operations, such as populateFromScale or populateFromRotationDegrees, rather than directly setting the actual numeric values of this transform. This function is useful for when the values are needed to be provided in bulk, for example for serialization.

To access these values in the same order as they are set here, use AffineTransform.getValues.

toString

public @NonNull String toString()

Extension functions

AndroidGraphicsConverter.populateFrom

public final @NonNull MutableAffineTransform AndroidGraphicsConverter.populateFrom(
    @NonNull MutableAffineTransform receiver,
    @NonNull Matrix matrix
)

Fills this MutableAffineTransform with the values from matrix.

If matrix is not an affine transform, throws IllegalArgumentException instead.

Leaves matrix unchanged. Returns this modified instance to allow chaining calls.

Throws
kotlin.IllegalArgumentException

if matrix is not an affine transform.