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 | 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 |
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 (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 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 224 of file matrix.h.
Referenced by GetDirectionScale(), impeller::DirectionalMorphologyFilterContents::GetFilterCoverage(), impeller::GaussianBlurFilterContents::GetFilterCoverage(), impeller::LocalMatrixFilterContents::GetFilterSourceCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::MatrixFilterContents::IsTranslationOnly(), 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 |
|
inlineconstexpr |
|
inlineconstexpr |
Scalar impeller::Matrix::GetDeterminant | ( | ) | const |
Definition at line 162 of file matrix.cc.
References e.
Referenced by impeller::LineGeometry::ComputePixelHalfWidth(), and Decompose().
Definition at line 311 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 306 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::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 325 of file matrix.h.
References m, and impeller::ScalarNearlyZero().
Referenced by impeller::testing::TEST().
|
inlineconstexpr |
Definition at line 350 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 363 of file matrix.h.
References m.
Referenced by impeller::RectGeometry::CoversArea(), impeller::LineGeometry::CoversArea(), impeller::RoundRectGeometry::CoversArea(), impeller::FillPathGeometry::CoversArea(), and impeller::TextContents::Render().
|
inlinestaticconstexpr |
Definition at line 69 of file matrix.h.
References Matrix().
Referenced by impeller::testing::TEST().
|
inlinestaticconstexpr |
Definition at line 497 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 462 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 471 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 489 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::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
Definition at line 182 of file matrix.h.
References Matrix(), and impeller::Radians::radians.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 195 of file matrix.h.
References Matrix(), and impeller::Radians::radians.
Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().
Definition at line 209 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 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::BM_StrokePolyline(), 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::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::DlDispatcher::drawShadow(), impeller::AtlasContents::GenerateSubAtlas(), impeller::Entity::GetShaderTransform(), MakeOrthographic(), impeller::PipelineBlend(), impeller::scene::importer::ProcessNode(), impeller::SolidRRectBlurContents::Render(), impeller::TiledTextureContents::RenderToSnapshot(), 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 423 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 409 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 402 of file matrix.h.
References m, impeller::Vector4::w, impeller::Vector4::x, impeller::Vector4::y, and impeller::Vector4::z.
|
inlineconstexpr |
Definition at line 247 of file matrix.h.
References m, Matrix(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 452 of file matrix.h.
Referenced by impeller::GaussianBlurFilterContents::CalculateUVs().
Definition at line 448 of file matrix.h.
References m, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.
Definition at line 442 of file matrix.h.
References m, impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.
Definition at line 436 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(), impeller::BorderMaskBlurFilterContents::GetFilterSourceCoverage(), and impeller::DirectionalMorphologyFilterContents::GetFilterSourceCoverage().
Definition at line 235 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 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(), 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 41 of file matrix.h.
Referenced by operator!=(), operator==(), and impeller::testing::TEST_P().