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 |
| 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 |
| Scalar | GetMaxBasisLength () const |
| Scalar | GetMaxBasisLengthXY () const |
| constexpr Vector3 | GetBasisX () const |
| constexpr Vector3 | GetBasisY () const |
| constexpr Vector3 | GetBasisZ () const |
| constexpr Vector3 | GetScale () const |
| constexpr Scalar | GetDirectionScale (Vector3 direction) const |
| constexpr bool | IsAffine () const |
| constexpr bool | HasPerspective () const |
| constexpr bool | IsAligned (Scalar tolerance=0) const |
| constexpr bool | IsIdentity () const |
| 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 |
| 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 Vector4 | TransformDirection (const Vector4 &v) const |
| constexpr Vector3 | TransformDirection (const Vector3 &v) const |
| constexpr Vector2 | TransformDirection (const Vector2 &v) 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 | MakeScale (const Vector2 &s) |
| static constexpr Matrix | MakeSkew (Scalar sx, Scalar sy) |
| static Matrix | MakeRotation (Quaternion q) |
| static Matrix | MakeRotation (Scalar 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 constexpr 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 constexpr Matrix | MakeLookAt (Vector3 position, Vector3 target, Vector3 up) |
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 46 of file matrix.h.
Referenced by Basis(), MakeColumn(), MakeRotation(), MakeRotationX(), MakeRotationY(), MakeRotationZ(), MakeRow(), MakeScale(), MakeSkew(), MakeTranslation(), Multiply(), operator+(), Scale(), and Translate().
|
explicit |
Definition at line 12 of file matrix.cc.
References impeller::Shear::e, impeller::Vector3::e, e, impeller::Vector4::e, impeller::MatrixDecomposition::perspective, impeller::MatrixDecomposition::rotation, impeller::MatrixDecomposition::scale, impeller::MatrixDecomposition::shear, impeller::MatrixDecomposition::translation, impeller::Quaternion::w, impeller::Quaternion::x, impeller::Quaternion::y, and impeller::Quaternion::z.
|
inlineconstexpr |
| std::optional< MatrixDecomposition > impeller::Matrix::Decompose | ( | ) | const |
Definition at line 217 of file matrix.cc.
References impeller::Vector3::Combine(), impeller::Vector3::Dot(), impeller::Vector3::e, e, impeller::Vector4::e, GetDeterminant(), Invert(), impeller::Vector3::Length(), impeller::Vector3::Normalize(), impeller::MatrixDecomposition::perspective, impeller::MatrixDecomposition::rotation, impeller::MatrixDecomposition::scale, impeller::MatrixDecomposition::shear, impeller::MatrixDecomposition::translation, Transpose(), impeller::Quaternion::w, 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().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
| Scalar impeller::Matrix::GetDeterminant | ( | ) | const |
Definition at line 306 of file matrix.h.
References Basis(), Invert(), impeller::Vector3::Length(), and impeller::Vector3::Normalize().
Referenced by impeller::testing::TEST().
| Scalar impeller::Matrix::GetMaxBasisLength | ( | ) | const |
| Scalar impeller::Matrix::GetMaxBasisLengthXY | ( | ) | const |
|
inlineconstexpr |
Definition at line 301 of file matrix.h.
References GetBasisX(), GetBasisY(), and GetBasisZ().
Referenced by impeller::DlDispatcher::drawShadow(), impeller::SceneContents::Render(), and impeller::testing::TEST_P().
|
inlineconstexpr |
| Matrix impeller::Matrix::Invert | ( | ) | const |
Definition at line 97 of file matrix.cc.
References m.
Referenced by Decompose(), GetDirectionScale(), impeller::MatrixFilterContents::GetFilterCoverage(), impeller::Snapshot::GetUVTransform(), impeller::scene::Skin::MakeFromFlatbuffer(), impeller::ColorSourceContents::SetEffectTransform(), impeller::scene::Node::SetGlobalTransform(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 320 of file matrix.h.
References m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 345 of file matrix.h.
References m.
Referenced by impeller::MatrixFilterContents::IsTranslationOnly(), impeller::scene::importer::ProcessNode(), and impeller::testing::TEST_P().
|
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 358 of file matrix.h.
References m.
Referenced by impeller::RectGeometry::CoversArea(), impeller::FillPathGeometry::CoversArea(), and impeller::TextContents::Render().
|
inlinestaticconstexpr |
Definition at line 68 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST().
|
inlinestaticconstexpr |
Definition at line 483 of file matrix.h.
References impeller::Vector3::Cross(), impeller::Vector3::Dot(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::scene::Camera::GetTransform(), and impeller::testing::TEST().
|
inlinestaticconstexpr |
Definition at line 448 of file matrix.h.
References impeller::TSize< T >::height, MakeScale(), MakeTranslation(), and impeller::TSize< T >::width.
Referenced by impeller::AdvancedBlend(), impeller::ComputeUVGeometryForRect(), impeller::VerticesGeometry::GetPositionBuffer(), impeller::VerticesGeometry::GetPositionColorBuffer(), impeller::VerticesGeometry::GetPositionUVBuffer(), ImGui_ImplImpeller_RenderDrawData(), impeller::PipelineBlend(), impeller::ClipContents::Render(), impeller::SolidRRectBlurContents::Render(), impeller::TextContents::Render(), impeller::TextureContents::Render(), impeller::AtlasContents::Render(), impeller::ClipRestoreContents::Render(), impeller::AtlasTextureContents::Render(), impeller::AtlasColorContents::Render(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 457 of file matrix.h.
References impeller::Radians::radians.
Referenced by impeller::scene::Camera::GetTransform(), MakePerspective(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 475 of file matrix.h.
References impeller::TSize< T >::height, MakePerspective(), and impeller::TSize< T >::width.
|
inlinestatic |
Definition at line 125 of file matrix.h.
References Matrix(), impeller::Quaternion::w, impeller::Quaternion::x, impeller::Quaternion::y, and impeller::Quaternion::z.
Referenced by impeller::scene::importer::ProcessNode(), impeller::testing::TEST(), and impeller::scene::testing::TEST_P().
Definition at line 150 of file matrix.h.
References Matrix(), impeller::Vector4::Normalize(), impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
Definition at line 181 of file matrix.h.
References Matrix(), and impeller::Radians::radians.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 194 of file matrix.h.
References Matrix(), and impeller::Radians::radians.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 208 of file matrix.h.
References Matrix(), and impeller::Radians::radians.
Referenced by impeller::Canvas::Rotate(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 82 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST().
Definition at line 112 of file matrix.h.
References MakeScale(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 103 of file matrix.h.
References Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::Snapshot::GetUVTransform(), MakeOrthographic(), MakeScale(), impeller::scene::importer::ParseGLTF(), impeller::scene::importer::ProcessNode(), impeller::SceneContents::Render(), impeller::TextureContents::RenderToSnapshot(), impeller::Canvas::Scale(), impeller::testing::TEST(), impeller::scene::testing::TEST_P(), and impeller::testing::TEST_P().
Definition at line 116 of file matrix.h.
References Matrix().
Referenced by impeller::Canvas::Skew(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 94 of file matrix.h.
References Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::AdvancedBlend(), impeller::DlDispatcher::drawShadow(), impeller::Canvas::DrawTextFrame(), impeller::AtlasContents::GenerateSubAtlas(), MakeOrthographic(), impeller::PipelineBlend(), impeller::scene::importer::ProcessNode(), impeller::SolidRRectBlurContents::Render(), impeller::TextureContents::RenderToSnapshot(), impeller::Contents::RenderToSnapshot(), impeller::Picture::Snapshot(), impeller::testing::TEST(), impeller::scene::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::Canvas::Translate().
|
inlineconstexpr |
Definition at line 418 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 404 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 397 of file matrix.h.
References m, impeller::Vector4::w, impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
|
inlineconstexpr |
Definition at line 245 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 443 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 437 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 431 of file matrix.h.
References m, impeller::Vector4::w, impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
Referenced by impeller::BorderMaskBlurFilterContents::GetFilterCoverage(), impeller::DirectionalMorphologyFilterContents::GetFilterCoverage(), and impeller::DirectionalGaussianBlurFilterContents::GetFilterCoverage().
Definition at line 233 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by ImGui_ImplImpeller_RenderDrawData(), operator+(), and operator-().
|
inlineconstexpr |
| union { ... } |
| Scalar impeller::Matrix::e[4][4] |
Definition at line 39 of file matrix.h.
Referenced by Decompose(), GetDeterminant(), GetMaxBasisLength(), GetMaxBasisLengthXY(), Matrix(), and std::operator<<().
| Scalar impeller::Matrix::m[16] |
Definition at line 38 of file matrix.h.
Referenced by Basis(), GetBasisX(), GetBasisY(), GetBasisZ(), HasPerspective(), Invert(), IsAffine(), IsAligned(), IsIdentity(), IsTranslationScaleOnly(), MatrixNear(), Multiply(), operator!=(), operator*(), operator+(), operator==(), Scale(), impeller::scene::importer::ToFBMatrix(), impeller::scene::importer::ToFBMatrixUniquePtr(), impeller::scene::importer::ToMatrix(), TransformDirection(), Translate(), and Transpose().
| Vector4 impeller::Matrix::vec[4] |
Definition at line 40 of file matrix.h.
Referenced by operator!=(), operator==(), and impeller::testing::TEST_P().