/** * 4x4 matrix used by SkCanvas and other parts of Skia. * * Skia assumes a right-handed coordinate system: * +X goes to the right * +Y goes down * +Z goes into the screen (away from the viewer)
*/ class SK_API SkM44 { public:
SkM44(const SkM44& src) = default;
SkM44& operator=(const SkM44& src) = default;
/** * Set this matrix to rotate about the specified unit-length axis vector, * by an angle specified by its sin() and cos(). * * This does not attempt to verify that axis.length() == 1 or that the sin,cos values * are correct.
*/
SkM44& setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle);
/** * Set this matrix to rotate about the specified unit-length axis vector, * by an angle specified in radians. * * This does not attempt to verify that axis.length() == 1.
*/
SkM44& setRotateUnit(SkV3 axis, SkScalar radians) { return this->setRotateUnitSinCos(axis, SkScalarSin(radians), SkScalarCos(radians));
}
/** * Set this matrix to rotate about the specified axis vector, * by an angle specified in radians. * * Note: axis is not assumed to be unit-length, so it will be normalized internally. * If axis is already unit-length, call setRotateAboutUnitRadians() instead.
*/
SkM44& setRotate(SkV3 axis, SkScalar radians);
SkM44& setConcat(const SkM44& a, const SkM44& b);
friend SkM44 operator*(const SkM44& a, const SkM44& b) { return SkM44(a, b);
}
SkM44& preConcat(const SkM44& m) { return this->setConcat(*this, m);
}
SkM44& postConcat(const SkM44& m) { return this->setConcat(m, *this);
}
/** * A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1]. * For most uses, a bottom row of [0, 0, 0, X] behaves like a non-perspective matrix, though * it will be categorized as perspective. Calling normalizePerspective() will change the * matrix such that, if its bottom row was [0, 0, 0, X], it will be changed to [0, 0, 0, 1] * by scaling the rest of the matrix by 1/X. * * | A B C D | | A/X B/X C/X D/X | * | E F G H | -> | E/X F/X G/X H/X | for X != 0 * | I J K L | | I/X J/X K/X L/X | * | 0 0 0 X | | 0 0 0 1 |
*/ void normalizePerspective();
/** Returns true if all elements of the matrix are finite. Returns false if any element is infinity, or NaN.
@return true if matrix has only finite elements
*/ bool isFinite() const { return SkIsFinite(fMat, 16); }
/** If this is invertible, return that in inverse and return true. If it is * not invertible, return false and leave the inverse parameter unchanged.
*/
[[nodiscard]] bool invert(SkM44* inverse) const;
/* When converting from SkM44 to SkMatrix, the third row and * column is dropped. When converting from SkMatrix to SkM44 * 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 ]
*/
SkMatrix asM33() const { return SkMatrix::MakeAll(fMat[0], fMat[4], fMat[12],
fMat[1], fMat[5], fMat[13],
fMat[3], fMat[7], fMat[15]);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.