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 | 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 |
| constexpr 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 | 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 | 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 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 | 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 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 47 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 |
The Matrix without its w components (without translation).
Definition at line 229 of file matrix.h.
Referenced by GetDirectionScale(), impeller::DirectionalMorphologyFilterContents::GetFilterCoverage(), impeller::LocalMatrixFilterContents::GetFilterSourceCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::MatrixFilterContents::IsTranslationOnly(), impeller::TextContents::Render(), and impeller::testing::TEST().
| std::optional< MatrixDecomposition > impeller::Matrix::Decompose | ( | ) | const |
Definition at line 209 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 |
Definition at line 305 of file matrix.h.
References m.
Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), and GetScale().
|
inlineconstexpr |
Definition at line 307 of file matrix.h.
References m.
Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), and GetScale().
|
inlineconstexpr |
| Scalar impeller::Matrix::GetDeterminant | ( | ) | const |
Definition at line 316 of file matrix.h.
References Basis(), Invert(), impeller::Vector3::Length(), and impeller::Vector3::Normalize().
Referenced by impeller::testing::TEST().
| Scalar impeller::Matrix::GetMaxBasisLength | ( | ) | const |
Definition at line 196 of file matrix.cc.
References e.
Referenced by impeller::Tessellator::FilledCircle(), impeller::Tessellator::FilledEllipse(), impeller::Tessellator::FilledRoundRect(), impeller::Tessellator::RoundCapLine(), and impeller::Tessellator::StrokedCircle().
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 311 of file matrix.h.
References GetBasisX(), GetBasisY(), and GetBasisZ().
Referenced by impeller::DlDispatcherBase::drawShadow(), impeller::SceneContents::Render(), and impeller::testing::TEST_P().
|
inlineconstexpr |
Definition at line 330 of file matrix.h.
References m.
Referenced by impeller::DlDispatcherBase::drawDisplayList(), IsAligned(), and impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 326 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::scene::Skin::MakeFromFlatbuffer(), impeller::ColorSourceContents::SetEffectTransform(), impeller::scene::Node::SetGlobalTransform(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 351 of file matrix.h.
References HasPerspective(), m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 336 of file matrix.h.
References HasPerspective2D(), m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 379 of file matrix.h.
References m.
Referenced by impeller::MatrixFilterContents::IsTranslationOnly(), 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 392 of file matrix.h.
References m.
Referenced by impeller::ClipContents::Render(), and impeller::TextContents::Render().
|
inlinestaticconstexpr |
Definition at line 69 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST(), impeller::TextFrameDispatcher::transform2DAffine(), and impeller::TextFrameDispatcher::transformFullPerspective().
|
inlinestaticconstexpr |
Definition at line 532 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 497 of file matrix.h.
References impeller::TSize< T >::height, MakeScale(), MakeTranslation(), scale, and impeller::TSize< T >::width.
Referenced by ImGui_ImplImpeller_RenderDrawData(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 506 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 524 of file matrix.h.
References impeller::TSize< T >::height, MakePerspective(), and impeller::TSize< T >::width.
|
inlinestatic |
Definition at line 126 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 151 of file matrix.h.
References 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 183 of file matrix.h.
References Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 198 of file matrix.h.
References Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 213 of file matrix.h.
References Matrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::Canvas::Rotate(), impeller::TextFrameDispatcher::rotate(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
inlinestaticconstexpr |
Definition at line 83 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST().
Definition at line 113 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::TRect< Scalar >::GetNormalizingTransform(), impeller::Entity::GetShaderTransform(), impeller::Snapshot::GetUVTransform(), MakeOrthographic(), MakeScale(), impeller::scene::importer::ParseGLTF(), impeller::scene::importer::ProcessNode(), impeller::SceneContents::Render(), impeller::TiledTextureContents::RenderToSnapshot(), impeller::TextureContents::RenderToSnapshot(), impeller::Canvas::Scale(), impeller::testing::TEST(), impeller::scene::testing::TEST_P(), and impeller::testing::TEST_P().
Definition at line 117 of file matrix.h.
References Matrix().
Referenced by impeller::Canvas::Skew(), impeller::TextFrameDispatcher::skew(), impeller::testing::TEST(), and impeller::testing::TEST_P().
|
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::DlDispatcherBase::drawShadow(), impeller::ExperimentalCanvas::DrawTextFrame(), impeller::TextFrameDispatcher::drawTextFrame(), impeller::Entity::GetShaderTransform(), MakeOrthographic(), impeller::PipelineBlend(), impeller::scene::importer::ProcessNode(), impeller::SolidRRectBlurContents::Render(), impeller::TiledTextureContents::RenderToSnapshot(), impeller::TextureContents::RenderToSnapshot(), impeller::Contents::RenderToSnapshot(), impeller::ExperimentalCanvas::Restore(), impeller::ExperimentalCanvas::SaveLayer(), impeller::Picture::Snapshot(), impeller::testing::TEST(), impeller::scene::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::Canvas::Translate().
|
inlineconstexpr |
Definition at line 452 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 438 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.
|
inlineconstexpr |
Definition at line 252 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by impeller::TextFrameDispatcher::scale().
Definition at line 487 of file matrix.h.
Referenced by impeller::GaussianBlurFilterContents::CalculateUVs().
Definition at line 483 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 477 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 471 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 465 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Referenced by impeller::testing::TEST().
Definition at line 240 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Referenced by ImGui_ImplImpeller_RenderDrawData(), operator+(), operator-(), and impeller::TextFrameDispatcher::translate().
|
inlineconstexpr |
| union { ... } |
| Scalar impeller::Matrix::e[4][4] |
Definition at line 40 of file matrix.h.
Referenced by Decompose(), GetDeterminant(), GetMaxBasisLength(), GetMaxBasisLengthXY(), Matrix(), and std::operator<<().
| Scalar impeller::Matrix::m[16] |
Definition at line 39 of file matrix.h.
Referenced by Basis(), GetBasisX(), GetBasisY(), GetBasisZ(), HasPerspective(), HasPerspective2D(), HasTranslation(), Invert(), IsAffine(), IsAligned(), IsAligned2D(), IsIdentity(), IsTranslationScaleOnly(), MatrixNear(), Multiply(), operator!=(), operator*(), operator+(), operator==(), Scale(), impeller::testing::TEST(), impeller::scene::importer::ToFBMatrix(), impeller::scene::importer::ToFBMatrixUniquePtr(), impeller::scene::importer::ToMatrix(), TransformDirection(), TransformHomogenous(), Translate(), and Transpose().
| Vector4 impeller::Matrix::vec[4] |
Definition at line 41 of file matrix.h.
Referenced by operator!=(), operator==(), and impeller::testing::TEST_P().