A 4x4 matrix using column-major storage. More...
#include <matrix.h>
Public Member Functions | |
constexpr | Matrix () |
constexpr | Matrix (Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15) |
Matrix (const MatrixDecomposition &decomposition) | |
constexpr Matrix | Basis () const |
The Matrix without its w components (without translation). More... | |
constexpr Matrix | To3x3 () const |
constexpr Matrix | Translate (const Vector3 &t) const |
constexpr Matrix | Scale (const Vector3 &s) const |
constexpr Matrix | Multiply (const Matrix &o) const |
constexpr Matrix | Transpose () const |
Matrix | Invert () const |
Scalar | GetDeterminant () const |
bool | IsInvertible () const |
Scalar | GetMaxBasisLengthXY () const |
constexpr Vector3 | GetBasisX () const |
constexpr Vector3 | GetBasisY () const |
constexpr Vector3 | GetBasisZ () const |
Vector3 | GetScale () const |
Scalar | GetDirectionScale (Vector3 direction) const |
bool | IsFinite () const |
constexpr bool | IsAffine () const |
constexpr bool | HasPerspective2D () const |
constexpr bool | HasPerspective () const |
constexpr bool | HasTranslation () const |
constexpr bool | IsAligned2D (Scalar tolerance=0) const |
constexpr bool | IsAligned (Scalar tolerance=0) const |
constexpr bool | IsIdentity () const |
constexpr bool | IsTranslationOnly () const |
Returns true if the matrix has no entries other than translation components. Note that an identity matrix meets this criteria. More... | |
constexpr bool | IsTranslationScaleOnly () const |
Returns true if the matrix has a scale-only basis and is non-projective. Note that an identity matrix meets this criteria. More... | |
std::optional< MatrixDecomposition > | Decompose () const |
bool | Equals (const Matrix &matrix, Scalar epsilon=1e-5f) const |
constexpr bool | operator== (const Matrix &m) const |
constexpr bool | operator!= (const Matrix &m) const |
Matrix | operator+ (const Vector3 &t) const |
Matrix | operator- (const Vector3 &t) const |
Matrix | operator* (const Matrix &m) const |
Matrix | operator+ (const Matrix &m) const |
constexpr Vector4 | operator* (const Vector4 &v) const |
constexpr Vector3 | operator* (const Vector3 &v) const |
constexpr Point | operator* (const Point &v) const |
constexpr Vector3 | TransformHomogenous (const Point &v) const |
constexpr Vector4 | TransformDirection (const Vector4 &v) const |
constexpr Vector3 | TransformDirection (const Vector3 &v) const |
constexpr Vector2 | TransformDirection (const Vector2 &v) const |
constexpr Quad | Transform (const Quad &quad) const |
Static Public Member Functions | |
static constexpr Matrix | MakeColumn (Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15) |
static constexpr Matrix | MakeRow (Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15) |
static constexpr Matrix | MakeTranslation (const Vector3 &t) |
static constexpr Matrix | MakeScale (const Vector3 &s) |
static constexpr Matrix | MakeTranslateScale (const Vector3 &s, const Vector3 &t) |
static constexpr Matrix | MakeScale (const Vector2 &s) |
static constexpr Matrix | MakeSkew (Scalar sx, Scalar sy) |
static Matrix | MakeRotation (Quaternion q) |
static Matrix | MakeRotation (Radians radians, const Vector4 &r) |
static Matrix | MakeRotationX (Radians r) |
static Matrix | MakeRotationY (Radians r) |
static Matrix | MakeRotationZ (Radians r) |
template<class T > | |
static constexpr Matrix | MakeOrthographic (TSize< T > size) |
static Matrix | MakePerspective (Radians fov_y, Scalar aspect_ratio, Scalar z_near, Scalar z_far) |
template<class T > | |
static constexpr Matrix | MakePerspective (Radians fov_y, TSize< T > size, Scalar z_near, Scalar z_far) |
static Matrix | MakeLookAt (Vector3 position, Vector3 target, Vector3 up) |
static Vector2 | CosSin (Radians radians) |
Public Attributes | |
union { | |
Scalar m [16] | |
Scalar e [4][4] | |
Vector4 vec [4] | |
}; | |
A 4x4 matrix using column-major storage.
Utility methods that need to make assumptions about normalized device coordinates must use the following convention: * Left-handed coordinate system. Positive rotation is clockwise about axis of rotation. * Lower left corner is -1.0f, -1.0. * Upper right corner is 1.0f, 1.0. * Visible z-space is from 0.0 to 1.0. * This is NOT the same as OpenGL! Be careful. * NDC origin is at (0.0f, 0.0f, 0.5f).
|
inlineconstexpr |
Constructs a default identity matrix.
Definition at line 47 of file matrix.h.
Referenced by Basis(), MakeColumn(), MakeRotation(), MakeRotationX(), MakeRotationY(), MakeRotationZ(), MakeRow(), MakeScale(), MakeSkew(), MakeTranslateScale(), MakeTranslation(), Multiply(), operator+(), Scale(), To3x3(), and Translate().
|
explicit |
Definition at line 12 of file matrix.cc.
References impeller::Shear::e, impeller::Vector3::e, impeller::Vector4::e, e, impeller::MatrixDecomposition::perspective, impeller::MatrixDecomposition::rotation, impeller::MatrixDecomposition::scale, impeller::MatrixDecomposition::shear, impeller::MatrixDecomposition::translation, impeller::Quaternion::w, x, impeller::Quaternion::x, impeller::Quaternion::y, and impeller::Quaternion::z.
|
inlineconstexpr |
The Matrix without its w
components (without translation).
Definition at line 239 of file matrix.h.
Referenced by impeller::TextContents::ComputeVertexData(), GetDirectionScale(), impeller::DirectionalMorphologyFilterContents::GetFilterCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::LocalMatrixFilterContents::GetFilterSourceCoverage(), impeller::SolidRRectLikeBlurContents::Render(), and impeller::testing::TEST().
Definition at line 618 of file matrix.h.
References impeller::Radians::radians.
Referenced by impeller::Arc::ComputeIterations(), impeller::Arc::GetTightArcBounds(), impeller::RSTransform::Make(), MakeRotation(), MakeRotationX(), MakeRotationY(), and MakeRotationZ().
std::optional< MatrixDecomposition > impeller::Matrix::Decompose | ( | ) | const |
Definition at line 200 of file matrix.cc.
References impeller::Vector3::Combine(), impeller::Vector3::Dot(), impeller::Vector3::e, impeller::Vector4::e, e, impeller::Vector3::GetLength(), Invert(), IsInvertible(), impeller::Vector3::Normalize(), impeller::MatrixDecomposition::perspective, impeller::MatrixDecomposition::rotation, impeller::MatrixDecomposition::scale, impeller::MatrixDecomposition::shear, impeller::MatrixDecomposition::translation, Transpose(), impeller::Quaternion::w, x, impeller::Quaternion::x, impeller::Vector3::x, impeller::Shear::xy, impeller::Shear::xz, impeller::Quaternion::y, impeller::Vector3::y, impeller::Shear::yz, impeller::Quaternion::z, and impeller::Vector3::z.
Referenced by impeller::testing::TEST().
Definition at line 453 of file matrix.h.
References impeller::saturated::b, m, and impeller::ScalarNearlyEqual().
|
inlineconstexpr |
Definition at line 335 of file matrix.h.
References m.
Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), and GetScale().
|
inlineconstexpr |
Definition at line 337 of file matrix.h.
References m.
Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), and GetScale().
|
inlineconstexpr |
Scalar impeller::Matrix::GetDeterminant | ( | ) | const |
Definition at line 346 of file matrix.h.
References Basis(), impeller::Vector3::GetLength(), Invert(), and impeller::Vector3::Normalize().
Referenced by impeller::testing::TEST().
|
inline |
Definition at line 323 of file matrix.h.
References e.
Referenced by impeller::LineContents::CalculatePerVertex(), impeller::Canvas::DrawTextFrame(), impeller::Tessellator::FilledArc(), impeller::Tessellator::FilledCircle(), impeller::Tessellator::FilledEllipse(), impeller::Tessellator::FilledRoundRect(), impeller::StrokeRectGeometry::GetPositionBuffer(), impeller::LineContents::Render(), impeller::Tessellator::RoundCapLine(), impeller::Tessellator::StrokedArc(), impeller::Tessellator::StrokedCircle(), and impeller::testing::TEST().
|
inline |
Definition at line 341 of file matrix.h.
References GetBasisX(), GetBasisY(), and GetBasisZ().
Referenced by impeller::DlDispatcherBase::drawShadow().
|
inlineconstexpr |
Definition at line 365 of file matrix.h.
References m.
Referenced by impeller::DlDispatcherBase::drawDisplayList(), impeller::FirstPassDispatcher::drawDisplayList(), IsAligned(), and impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 361 of file matrix.h.
References m.
Referenced by IsAligned2D(), and impeller::testing::TEST().
|
inlineconstexpr |
Matrix impeller::Matrix::Invert | ( | ) | const |
Definition at line 97 of file matrix.cc.
References m.
Referenced by Decompose(), GetDirectionScale(), impeller::MatrixFilterContents::GetFilterCoverage(), impeller::LocalMatrixFilterContents::GetFilterSourceCoverage(), impeller::Snapshot::GetUVTransform(), impeller::TextShadowCache::Lookup(), impeller::SolidRRectLikeBlurContents::Render(), impeller::Canvas::Restore(), impeller::Canvas::SaveLayer(), impeller::ColorSourceContents::SetEffectTransform(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 386 of file matrix.h.
References HasPerspective(), m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 371 of file matrix.h.
References HasPerspective2D(), m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inline |
Definition at line 351 of file matrix.h.
References impeller::Vector4::IsFinite(), and vec.
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 414 of file matrix.h.
References m.
Referenced by impeller::testing::TEST_P(), and impeller::interop::testing::TEST_P().
|
inline |
Definition at line 321 of file matrix.h.
References GetDeterminant().
Referenced by Decompose(), and impeller::testing::TEST_P().
|
inlineconstexpr |
|
inlineconstexpr |
Returns true if the matrix has a scale-only basis and is non-projective. Note that an identity matrix meets this criteria.
Definition at line 440 of file matrix.h.
References m.
Referenced by impeller::TextContents::ComputeVertexData(), and impeller::TextContents::Render().
|
inlinestaticconstexpr |
Definition at line 69 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST(), impeller::FirstPassDispatcher::transform2DAffine(), and impeller::FirstPassDispatcher::transformFullPerspective().
|
inlinestatic |
Definition at line 601 of file matrix.h.
References impeller::Vector3::Cross(), impeller::Vector3::Dot(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::testing::TEST().
|
inlinestaticconstexpr |
Definition at line 566 of file matrix.h.
References impeller::TSize< T >::height, MakeScale(), MakeTranslation(), and impeller::TSize< T >::width.
Referenced by ImGui_ImplImpeller_RenderDrawData(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestatic |
Definition at line 575 of file matrix.h.
References impeller::Radians::radians.
Referenced by MakePerspective(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 593 of file matrix.h.
References impeller::TSize< T >::height, MakePerspective(), and impeller::TSize< T >::width.
|
inlinestatic |
Definition at line 136 of file matrix.h.
References Matrix(), impeller::Quaternion::w, impeller::Quaternion::x, impeller::Quaternion::y, and impeller::Quaternion::z.
Referenced by impeller::testing::TEST().
Definition at line 161 of file matrix.h.
References CosSin(), Matrix(), impeller::Vector4::Normalize(), impeller::TPoint< T >::x, impeller::Vector4::x, impeller::TPoint< T >::y, impeller::Vector4::y, and impeller::Vector4::z.
Definition at line 193 of file matrix.h.
References CosSin(), Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 208 of file matrix.h.
References CosSin(), Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 223 of file matrix.h.
References CosSin(), Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::FirstPassDispatcher::rotate(), impeller::Canvas::Rotate(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 83 of file matrix.h.
References Matrix().
Referenced by impeller::RSTransform::GetMatrix(), impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 123 of file matrix.h.
References MakeScale(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 104 of file matrix.h.
References Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::TextContents::ComputeVertexData(), impeller::TRect< T >::GetNormalizingTransform(), impeller::Snapshot::GetUVTransform(), MakeOrthographic(), MakeScale(), impeller::TextureContents::RenderToSnapshot(), impeller::TiledTextureContents::RenderToSnapshot(), impeller::Canvas::Scale(), impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 127 of file matrix.h.
References Matrix().
Referenced by impeller::FirstPassDispatcher::skew(), impeller::Canvas::Skew(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 113 of file matrix.h.
References Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::Canvas::DrawImageRect(), impeller::Entity::GetShaderTransform(), and impeller::testing::TEST().
|
inlinestaticconstexpr |
Definition at line 95 of file matrix.h.
References Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::AdvancedBlend(), impeller::Canvas::ClipGeometry(), impeller::DlDispatcherBase::drawShadow(), impeller::FirstPassDispatcher::drawTextFrame(), impeller::Canvas::DrawTextFrame(), impeller::TextFrame::GetOffsetTransform(), MakeOrthographic(), impeller::PipelineBlend(), impeller::SolidRRectLikeBlurContents::Render(), impeller::Contents::RenderToSnapshot(), impeller::TextureContents::RenderToSnapshot(), impeller::TiledTextureContents::RenderToSnapshot(), impeller::Canvas::Restore(), impeller::Canvas::SaveLayer(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::Canvas::Translate().
|
inlineconstexpr |
Definition at line 521 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 507 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 500 of file matrix.h.
References m, impeller::Vector4::w, impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
Definition at line 492 of file matrix.h.
References Translate().
|
inlineconstexpr |
Definition at line 275 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::FirstPassDispatcher::scale(), and impeller::testing::TEST_P().
|
inlineconstexpr |
Definition at line 556 of file matrix.h.
Referenced by impeller::GaussianBlurFilterContents::CalculateUVs(), and impeller::testing::TEST_P().
Definition at line 552 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 546 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 540 of file matrix.h.
References m, impeller::Vector4::w, impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
Referenced by impeller::BorderMaskBlurFilterContents::GetFilterSourceCoverage(), and impeller::DirectionalMorphologyFilterContents::GetFilterSourceCoverage().
Definition at line 534 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST().
Definition at line 263 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by ImGui_ImplImpeller_RenderDrawData(), operator+(), operator-(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::FirstPassDispatcher::translate().
|
inlineconstexpr |
union { ... } |
Scalar impeller::Matrix::e[4][4] |
Definition at line 40 of file matrix.h.
Referenced by Decompose(), GetDeterminant(), GetMaxBasisLengthXY(), Matrix(), std::operator<<(), and impeller::testing::TEST().
Scalar impeller::Matrix::m[16] |
Definition at line 39 of file matrix.h.
Referenced by Basis(), impeller::TextContents::ComputeVertexData(), Equals(), impeller::interop::FromImpellerType(), GetBasisX(), GetBasisY(), GetBasisZ(), HasPerspective(), HasPerspective2D(), HasTranslation(), Invert(), IsAffine(), IsAligned(), IsAligned2D(), IsIdentity(), IsTranslationOnly(), IsTranslationScaleOnly(), MatrixNear(), Multiply(), operator!=(), operator*(), operator+(), operator==(), Scale(), impeller::testing::TEST(), To3x3(), impeller::interop::ToSkMatrix(), TransformDirection(), TransformHomogenous(), Translate(), and Transpose().
Vector4 impeller::Matrix::vec[4] |
Definition at line 41 of file matrix.h.
Referenced by IsFinite(), operator!=(), operator==(), and impeller::testing::TEST_P().