Interface Matrixc
Matrix const &matrix
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
TypeMaskstatic final int
TypeMaskstatic final int
TypeMaskstatic final int
TypeMaskstatic final int
TypeMask -
Method Summary
Modifier and TypeMethodDescriptionclone()
float
differentialAreaScale
(float px, float py) Returns the differential area scale factor for a local point 'p' that will be transformed by 'm' (which may have perspective).boolean
float
Returns the maximum scaling factor of this matrix by decomposing the scaling and shearing elements.
Returns -1 if scale factor overflows or this matrix contains perspective.float
getMaxScale
(float px, float py) Returns the maximum scaling factor of this matrix by decomposing the scaling and shearing elements.float
Returns the minimum scaling factor of this matrix by decomposing the scaling and shearing elements.
Returns -1 if scale factor overflows or this matrix contains perspective.float
getMinScale
(float px, float py) Returns the minimum scaling factor of this matrix by decomposing the scaling and shearing elements.float
Returns factor scaling input x-axis relative to input y-axis.float
Returns factor scaling input y-axis relative to input x-axis.float
Returns scale factor multiplied by x-axis input, contributing to x-axis output.float
Returns scale factor multiplied by y-axis input, contributing to y-axis output.float
Returns scale factor multiplied by y-axis input, contributing to x-axis output.float
Returns scale factor multiplied by x-axis input, contributing to y-axis output.float
Returns translation contributing to x-axis output.float
Returns translation contributing to y-axis output.int
getType()
Returns a bit field describing the transformations the matrix may perform.int
hashCode()
boolean
Returns whether this matrix contains perspective elements.boolean
Compute the inverse of this matrix.boolean
Returns whether this matrix transforms rect to another rect.boolean
isFinite()
Returns true if all elements of the matrix are finite.boolean
Returns true if this matrix is identity.boolean
Returns whether this matrix at most scales and translates.boolean
Returns true if this matrix contains only translation, rotation, reflection, and uniform scale.boolean
Returns whether this matrix is identity, or translates.float
localAARadius
(float left, float top, float right, float bottom) Return the minimum distance needed to move in local (pre-transform) space to ensure that the transformed coordinates are at least 1px away from the original mapped point.float
localAARadius
(Rect2fc bounds) Return the minimum distance needed to move in local (pre-transform) space to ensure that the transformed coordinates are at least 1px away from the original mapped point.float
m11()
Same asgetScaleX()
.float
m12()
Same asgetShearY()
.float
m14()
Same asgetPerspX()
.float
m21()
Same asgetShearX()
.float
m22()
Same asgetScaleY()
.float
m24()
Same asgetPerspY()
.float
m41()
Same asgetTranslateX()
.float
m42()
Same asgetTranslateY()
.float
m44()
Returns the last element of the matrix, the perspective bias.default void
mapPoint
(float[] p) default void
mapPoints
(float[] pts) default void
mapPoints
(float[] src, float[] dst, int count) default void
mapPoints
(float[] pts, int count) void
mapPoints
(float[] src, int srcPos, float[] dst, int dstPos, int count) Maps src point array of length count to dst point array of equal or greater length.default void
mapPoints
(float[] pts, int pos, int count) void
Map a rectangle points in the X-Y plane to get the maximum bounds.default boolean
Sets rect to bounds of rect corners mapped by this matrix.boolean
Sets dst to bounds of src corners mapped by this matrix.default void
Map a rectangle points in the X-Y plane to get the maximum bounds.default void
Map a rectangle points in the X-Y plane to get the maximum bounds.default void
Map a rectangle points in the X-Y plane to get the maximum bounds.void
mapRectOut
(float left, float top, float right, float bottom, Rect2i dst) Map a rectangle points in the X-Y plane to get the maximum bounds.default void
mapRectOut
(Rect2fc r, Rect2i dst) Map a rectangle points in the X-Y plane to get the maximum bounds.default void
mapRectOut
(Rect2i r) Map a rectangle points in the X-Y plane to get the maximum bounds.default void
mapRectOut
(Rect2ic r, Rect2i dst) Map a rectangle points in the X-Y plane to get the maximum bounds.boolean
Returns true if this matrix contains only translation, rotation, reflection, and scale.void
store
(float[] a) Store this matrix into the give float array in row-major order.void
store
(float[] a, int offset) Store this matrix into the give float array in row-major order.void
store
(long p) Get this matrix data, store them into an address (UNSAFE).void
Store this matrix elements to the given matrix.void
store
(ByteBuffer a) Store this matrix into the give float array in row-major order.void
store
(FloatBuffer a) Store this matrix into the give float array in row-major order.void
storeAligned
(long p) Get this matrix data, store them into an address (UNSAFE).void
Store this matrix into the give float array in row-major order.void
Store this matrix into the give float array in row-major order.Converts this 3x3 matrix to 4x4 matrix, the third row and column are identity.void
Converts this 3x3 matrix to 4x4 matrix, the third row and column are identity.toString()
-
Field Details
-
kIdentity_Mask
static final int kIdentity_MaskTypeMaskEnum of bit fields for mask returned by
getType()
. Used to identify the complexity of Matrix, for optimizations.- See Also:
-
kTranslate_Mask
static final int kTranslate_MaskTypeMaskEnum of bit fields for mask returned by
getType()
. Used to identify the complexity of Matrix, for optimizations.- See Also:
-
kScale_Mask
static final int kScale_MaskTypeMaskEnum of bit fields for mask returned by
getType()
. Used to identify the complexity of Matrix, for optimizations.- See Also:
-
kAffine_Mask
static final int kAffine_MaskTypeMaskEnum of bit fields for mask returned by
getType()
. Used to identify the complexity of Matrix, for optimizations.- See Also:
-
kPerspective_Mask
static final int kPerspective_MaskTypeMaskEnum of bit fields for mask returned by
getType()
. Used to identify the complexity of Matrix, for optimizations.- See Also:
-
-
Method Details
-
getType
int getType()Returns a bit field describing the transformations the matrix may perform. The bit field is computed conservatively, so it may include false positives. For example, when Perspective_Mask is set, all other bits are set.- Returns:
- Identity_Mask, or combinations of: Translate_Mask, Scale_Mask, Affine_Mask, Perspective_Mask
-
isIdentity
boolean isIdentity()Returns true if this matrix is identity.- Returns:
true
if this matrix is identity.
-
isScaleTranslate
boolean isScaleTranslate()Returns whether this matrix at most scales and translates.- Returns:
true
if this matrix is scales, translates, or both.
-
isTranslate
boolean isTranslate()Returns whether this matrix is identity, or translates.- Returns:
true
if this matrix is identity, or translates
-
isAxisAligned
boolean isAxisAligned()Returns whether this matrix transforms rect to another rect. If true, this matrix is identity, or/and scales, or mirrors on axes. In all cases, this matrix is affine and may also have translation.- Returns:
- true if this matrix transform one rect into another
-
preservesRightAngles
boolean preservesRightAngles()Returns true if this matrix contains only translation, rotation, reflection, and scale. Scale may differ along rotated axes.
Returns false if this matrix shearing, perspective, or degenerate forms that collapse to a line or point.Preserves right angles, but not requiring that the arms of the angle retain equal lengths.
- Returns:
- true if this matrix only rotates, scales, translates
-
hasPerspective
boolean hasPerspective()Returns whether this matrix contains perspective elements.- Returns:
- true if this matrix is in most general form
-
isSimilarity
boolean isSimilarity()Returns true if this matrix contains only translation, rotation, reflection, and uniform scale. Returns false if this matrix contains different scales, shearing, perspective, or degenerate forms that collapse to a line or point.Describes that the matrix makes rendering with and without the matrix are visually alike; a transformed circle remains a circle. Mathematically, this is referred to as similarity of a Euclidean space, or a similarity transformation.
Preserves right angles, keeping the arms of the angle equal lengths.
- Returns:
- true if this matrix only rotates, uniformly scales, translates
-
m11
float m11()Same asgetScaleX()
. -
m12
float m12()Same asgetShearY()
. -
m14
float m14()Same asgetPerspX()
. -
m21
float m21()Same asgetShearX()
. -
m22
float m22()Same asgetScaleY()
. -
m24
float m24()Same asgetPerspY()
. -
m41
float m41()Same asgetTranslateX()
. -
m42
float m42()Same asgetTranslateY()
. -
m44
float m44()Returns the last element of the matrix, the perspective bias. -
getScaleX
float getScaleX()Returns scale factor multiplied by x-axis input, contributing to x-axis output. With mapPoints(), scales Point along the x-axis.- Returns:
- horizontal scale factor
-
getScaleY
float getScaleY()Returns scale factor multiplied by y-axis input, contributing to y-axis output. With mapPoints(), scales Point along the y-axis.- Returns:
- vertical scale factor
-
getShearY
float getShearY()Returns scale factor multiplied by x-axis input, contributing to y-axis output. With mapPoints(), shears Point along the y-axis. Shearing both axes can rotate Point.- Returns:
- vertical shear factor
-
getShearX
float getShearX()Returns scale factor multiplied by y-axis input, contributing to x-axis output. With mapPoints(), shears Point along the x-axis. Shearing both axes can rotate Point.- Returns:
- horizontal shear factor
-
getTranslateX
float getTranslateX()Returns translation contributing to x-axis output. With mapPoints(), moves Point along the x-axis.- Returns:
- horizontal translation factor
-
getTranslateY
float getTranslateY()Returns translation contributing to y-axis output. With mapPoints(), moves Point along the y-axis.- Returns:
- vertical translation factor
-
getPerspX
float getPerspX()Returns factor scaling input x-axis relative to input y-axis.- Returns:
- input x-axis perspective factor
-
getPerspY
float getPerspY()Returns factor scaling input y-axis relative to input x-axis.- Returns:
- input y-axis perspective factor
-
store
Store this matrix elements to the given matrix.- Parameters:
dst
- the matrix to store
-
store
void store(@Nonnull float[] a) Store this matrix into the give float array in row-major order.- Parameters:
a
- the array to store into
-
store
void store(@Nonnull float[] a, int offset) Store this matrix into the give float array in row-major order.- Parameters:
a
- the array to store intooffset
- the element offset
-
store
Store this matrix into the give float array in row-major order.- Parameters:
a
- the pointer of the array to store
-
storeAligned
Store this matrix into the give float array in row-major order. The data matches std140 layout so it is not tightly packed.- Parameters:
a
- the pointer of the array to store
-
store
Store this matrix into the give float array in row-major order.- Parameters:
a
- the pointer of the array to store
-
storeAligned
Store this matrix into the give float array in row-major order. The data matches std140 layout so it is not tightly packed.- Parameters:
a
- the pointer of the array to store
-
store
void store(long p) Get this matrix data, store them into an address (UNSAFE). NOTE: This method does not perform memory security checks.- Parameters:
p
- the pointer of the array to store
-
storeAligned
void storeAligned(long p) Get this matrix data, store them into an address (UNSAFE). The data matches std140 layout so it is not tightly packed. NOTE: This method does not perform memory security checks.- Parameters:
p
- the pointer of the array to store, must be aligned
-
toMatrix4
Converts this 3x3 matrix to 4x4 matrix, the third row and column are identity.[ a b c ] [ a b 0 c ] [ d e f ] -> [ d e 0 f ] [ g h i ] [ 0 0 1 0 ] [ g h 0 i ]
-
toMatrix4
Converts this 3x3 matrix to 4x4 matrix, the third row and column are identity.[ a b c ] [ a b 0 c ] [ d e f ] -> [ d e 0 f ] [ g h i ] [ 0 0 1 0 ] [ g h 0 i ]
-
invert
Compute the inverse of this matrix. The dest matrix will be the inverse of this matrix if this matrix is invertible, otherwise its values will be preserved.- Parameters:
dest
- the destination matrix, may be null- Returns:
true
if this matrix is invertible.
-
mapRect
Sets rect to bounds of rect corners mapped by this matrix. Returns true if mapped corners are dst corners. -
mapRect
Sets dst to bounds of src corners mapped by this matrix. Returns true if mapped corners are dst corners. -
mapRect
Map a rectangle points in the X-Y plane to get the maximum bounds. -
mapRect
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
out
- the round values
-
mapRect
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
out
- the round values
-
mapRect
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
dst
- the round values
-
mapRectOut
Map a rectangle points in the X-Y plane to get the maximum bounds. -
mapRectOut
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
dst
- the round out values
-
mapRectOut
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
dst
- the round out values
-
mapRectOut
Map a rectangle points in the X-Y plane to get the maximum bounds.- Parameters:
dst
- the round out values
-
mapPoint
default void mapPoint(float[] p) - See Also:
-
mapPoints
default void mapPoints(float[] pts) - See Also:
-
mapPoints
default void mapPoints(float[] pts, int count) - See Also:
-
mapPoints
default void mapPoints(float[] pts, int pos, int count) - See Also:
-
mapPoints
default void mapPoints(float[] src, float[] dst, int count) - See Also:
-
mapPoints
void mapPoints(float[] src, int srcPos, float[] dst, int dstPos, int count) Maps src point array of length count to dst point array of equal or greater length. Points are mapped by multiplying each point by this matrix. Given:| A B C | | x | | D E F |, pt = | y | | G H I | | 1 |
wherefor (i = 0; i invalid input: '<' count; ++i) { x = src[srcPos + (i invalid input: '<'invalid input: '<' 1)] y = src[srcPos + (i invalid input: '<'invalid input: '<' 1) + 1] }
each dst point is computed as:|A B C| |x| Ax+By+C Dx+Ey+F |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- |G H I| |1| Gx+Hy+I Gx+Hy+I
src and dst may point to the same array.
- Parameters:
src
- points to transformdst
- array for mapped pointscount
- number of points to transform
-
getMinScale
float getMinScale()Returns the minimum scaling factor of this matrix by decomposing the scaling and shearing elements.
Returns -1 if scale factor overflows or this matrix contains perspective.- Returns:
- minimum scale factor
-
getMaxScale
float getMaxScale()Returns the maximum scaling factor of this matrix by decomposing the scaling and shearing elements.
Returns -1 if scale factor overflows or this matrix contains perspective.- Returns:
- maximum scale factor
-
getMinScale
float getMinScale(float px, float py) Returns the minimum scaling factor of this matrix by decomposing the scaling and shearing elements. When this matrix has perspective, the scaling factor is specific to the given point p.
Returns -1 if scale factor overflows.- Parameters:
px
- the x-coord of pointpy
- the y-coord of point- Returns:
- minimum scale factor
-
getMaxScale
float getMaxScale(float px, float py) Returns the maximum scaling factor of this matrix by decomposing the scaling and shearing elements. When this matrix has perspective, the scaling factor is specific to the given point p.
Returns -1 if scale factor overflows.- Parameters:
px
- the x-coord of pointpy
- the y-coord of point- Returns:
- maximum scale factor
-
differentialAreaScale
float differentialAreaScale(float px, float py) Returns the differential area scale factor for a local point 'p' that will be transformed by 'm' (which may have perspective). If 'm' does not have perspective, this scale factor is constant regardless of 'p'; when it does have perspective, it is specific to that point.This can be crudely thought of as "device pixel area" / "local pixel area" at 'p'.
Returns positive infinity if the transformed homogeneous point has w invalid input: '<'= 0.
The return value is equivalent to
getMinScale(float, float)
timesgetMaxScale(float, float)
.- Parameters:
px
- the x-coord of pointpy
- the y-coord of point
-
localAARadius
Return the minimum distance needed to move in local (pre-transform) space to ensure that the transformed coordinates are at least 1px away from the original mapped point. This minimum distance is specific to the given local 'bounds' since the scale factors change with perspective.If the bounds will be clipped by the w=0 plane or otherwise is ill-conditioned, this will return positive infinity.
-
localAARadius
float localAARadius(float left, float top, float right, float bottom) Return the minimum distance needed to move in local (pre-transform) space to ensure that the transformed coordinates are at least 1px away from the original mapped point. This minimum distance is specific to the given local 'bounds' since the scale factors change with perspective.If the bounds will be clipped by the w=0 plane or otherwise is ill-conditioned, this will return positive infinity.
-
isFinite
boolean isFinite()Returns true if all elements of the matrix are finite. Returns false if any element is infinity, or NaN.- Returns:
- true if matrix has only finite elements
-
hashCode
int hashCode() -
equals
-
toString
String toString() -
clone
-