Class Matrix33
- java.lang.Object
-
- io.github.humbleui.skija.Matrix33
-
public class Matrix33 extends java.lang.ObjectMatrix holds a 3x3 matrix for transforming coordinates. This allows mapping Point and vectors with translation, scaling, skewing, rotation, and perspective.
Matrix includes a hidden variable that classifies the type of matrix to improve performance. Matrix is not thread safe unless getType() is called first.
- See Also:
- https://fiddle.skia.org/c/@Matrix_063
-
-
Constructor Summary
Constructors Constructor Description Matrix33(float... mat)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Matrix44asMatrix44()When converting from Matrix33 to Matrix44, the third row and column remain as identity:protected booleancanEqual(java.lang.Object other)booleanequals(java.lang.Object o)float[]getMat()Matrix33 elements are in row-major order.inthashCode()@NotNull Matrix33makeConcat(Matrix33 other)Creates Matrix33 by multiplying this by other.@NotNull Matrix33makePreScale(float sx, float sy)static @NotNull Matrix33makeRotate(float deg)Creates a Matrix33 to rotate by |deg| about a pivot point at (0, 0).static @NotNull Matrix33makeRotate(float deg, float pivotx, float pivoty)Creates a Matrix33 to rotate by |deg| about a pivot point at (pivotx, pivoty).static @NotNull Matrix33makeRotate(float deg, io.github.humbleui.types.Point pivot)Creates a Matrix33 to rotate by |deg| about a pivot point at pivot.static @NotNull Matrix33makeScale(float s)Creates a Matrix33 to scale by s.static @NotNull Matrix33makeScale(float sx, float sy)Creates a Matrix33 to scale by (sx, sy).static @NotNull Matrix33makeSkew(float sx, float sy)Creates a Matrix33 to skew by (sx, sy).static @NotNull Matrix33makeTranslate(float dx, float dy)Creates a Matrix33 to translate by (dx, dy).java.lang.StringtoString()
-
-
-
Field Detail
-
_mat
@Internal public final float[] _mat
Matrix33 elements are in row-major order.
| scaleX skewX transX | | skewY scaleY transY | | persp0 persp1 persp2 |
-
IDENTITY
@NotNull public static final @NotNull Matrix33 IDENTITY
An identity Matrix33:| 1 0 0 | | 0 1 0 | | 0 0 1 |
-
-
Method Detail
-
makeTranslate
@NotNull @Contract("_, _ -> new") public static @NotNull Matrix33 makeTranslate(float dx, float dy)Creates a Matrix33 to translate by (dx, dy). Returned matrix is:
| 1 0 dx | | 0 1 dy | | 0 0 1 |- Parameters:
dx- horizontal translationdy- vertical translation- Returns:
- Matrix33 with translation
-
makeScale
@NotNull public static @NotNull Matrix33 makeScale(float s)
Creates a Matrix33 to scale by s. Returned matrix is:
| s 0 0 | | 0 s 0 | | 0 0 1 |- Parameters:
s- scale factor- Returns:
- Matrix33 with scale
-
makeScale
@NotNull public static @NotNull Matrix33 makeScale(float sx, float sy)
Creates a Matrix33 to scale by (sx, sy). Returned matrix is:
| sx 0 0 | | 0 sy 0 | | 0 0 1 |- Parameters:
sx- horizontal scale factorsy- vertical scale factor- Returns:
- Matrix33 with scale
-
makePreScale
@NotNull public @NotNull Matrix33 makePreScale(float sx, float sy)
-
makeConcat
@NotNull public @NotNull Matrix33 makeConcat(Matrix33 other)
Creates Matrix33 by multiplying this by other. This can be thought of mapping by other before applying Matrix.
Given:
| A B C | | J K L | this = | D E F |, other = | M N O | | G H I | | P Q R |Returns:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | this * other = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |- Parameters:
other- Matrix on right side of multiply expression- Returns:
- this multiplied by other
-
makeRotate
@NotNull public static @NotNull Matrix33 makeRotate(float deg)
Creates a Matrix33 to rotate by |deg| about a pivot point at (0, 0).- Parameters:
deg- rotation angle in degrees (positive rotates clockwise)- Returns:
- Matrix33 with rotation
-
makeRotate
@NotNull public static @NotNull Matrix33 makeRotate(float deg, io.github.humbleui.types.Point pivot)
Creates a Matrix33 to rotate by |deg| about a pivot point at pivot.- Parameters:
deg- rotation angle in degrees (positive rotates clockwise)pivot- pivot point- Returns:
- Matrix33 with rotation
-
makeRotate
@NotNull public static @NotNull Matrix33 makeRotate(float deg, float pivotx, float pivoty)
Creates a Matrix33 to rotate by |deg| about a pivot point at (pivotx, pivoty).- Parameters:
deg- rotation angle in degrees (positive rotates clockwise)pivotx- x-coord of pivotpivoty- y-coord of pivot- Returns:
- Matrix33 with rotation
-
makeSkew
@NotNull public static @NotNull Matrix33 makeSkew(float sx, float sy)
Creates a Matrix33 to skew by (sx, sy). Returned matrix is:
| 1 sx 0 | | sy 1 0 | | 0 0 1 |- Parameters:
sx- horizontal skew factorsy- vertical skew factor- Returns:
- Matrix33 with skew
-
asMatrix44
@NotNull public @NotNull Matrix44 asMatrix44()
When converting from Matrix33 to Matrix44, the third row and column remain as 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 ]
-
getMat
public float[] getMat()
Matrix33 elements are in row-major order.
| scaleX skewX transX | | skewY scaleY transY | | persp0 persp1 persp2 |
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-