mat4.ixx File
4x4 matrix type and utilities. More...
Included Headers
#include <cassert>
#include <functional>
#include <cstddef>
#include <cmath>
#include <helios.math.concepts>
#include <helios.math.types:vec4>
#include <helios.math.utils>
#include <helios.math.TransformType>
Namespaces Index
| namespace | helios |
| namespace | math |
Classes Index
| struct | mat4<T> |
|
Represents a 4x4 matrix, stored in column-major order. More... | |
Description
4x4 matrix type and utilities.
File Listing
The file content with the documentation metadata removed is:
22export namespace helios::math {
107 return mat4<T>(1);
132 constexpr const T& operator()(const size_t row, const size_t col) const {
159 constexpr T& operator()(const size_t row, const size_t col) {
182 static const T eps = static_cast<T>(helios::math::EPSILON_LENGTH);
184 const auto* leftPtr = value_ptr(*this);
185 const auto* rgtPtr = value_ptr(rgt);
205 constexpr bool operator==(const mat4<T>& rgt) const {
207 const auto* leftPtr = value_ptr(*this);
208 const auto* rgtPtr = value_ptr(rgt);
229 mat4<T> A{};
256 return vec4<T>{
274 return mat4<T>{
294 helios::math::mat4<T> transpose() const noexcept {
296 return helios::math::mat4<T>{
310 helios::math::vec4<T> column(unsigned int i) const noexcept {
313 return helios::math::vec4<T>{
325 constexpr helios::math::mat4<T> inverse() const noexcept {
328 const auto a = column(0).toVec3();
329 const auto b = column(1).toVec3();
330 const auto c = column(2).toVec3();
331 const auto d = column(3).toVec3();
338 auto s = helios::math::cross(a, b);
339 auto t = helios::math::cross(c, d);
343 T invDet = static_cast<T>(1) / (helios::math::dot(s, v) + helios::math::dot(t, u));
350 auto r0 = (helios::math::cross(b, v)) + t*y;
351 auto r1 = (helios::math::cross(v, a)) - t*x;
352 auto r2 = (helios::math::cross(d, u)) + s*w;
353 auto r3 = (helios::math::cross(u, c)) - s*z;
355 return helios::math::mat4<T>{
356 r0[0], r0[1], r0[2], -helios::math::dot(b, t),
357 r1[0], r1[1], r1[2], helios::math::dot(a, t),
358 r2[0], r2[1], r2[2], -helios::math::dot(d, s),
359 r3[0], r3[1], r3[2], helios::math::dot(c, s)
371 helios::math::vec3<T> translation() const noexcept {
373 return helios::math::vec3<T>{
388 helios::math::mat4<T> withTranslation(helios::math::vec3<T> v) const noexcept {
390 return helios::math::mat4<T>{
409 helios::math::mat4<T> withScaling(helios::math::vec3<T> v) const noexcept {
411 return helios::math::mat4<T>{
430 helios::math::mat4<T> withTranslation(helios::math::vec4<T> v) const noexcept {
432 return helios::math::mat4<T>{
466 helios::math::mat4<T> decompose(const helios::math::TransformType type) const noexcept {
468 if (type == helios::math::TransformType::All) {
472 auto id = identity();
473 if (helios::math::transformTypeMatch(type, helios::math::TransformType::Translation)) {
480 && helios::math::transformTypeMatch(type, helios::math::TransformType::Scale)) {
486 const auto bx = vec3<T>(m(0, 0), m(1, 0), m(2, 0));
487 const auto by = vec3<T>(m(0, 1), m(1, 1), m(2, 1));
488 const auto bz = vec3<T>(m(0, 2), m(1, 2), m(2, 2));
494 if (helios::math::transformTypeMatch(type, helios::math::TransformType::Rotation)) {
502 } else if (helios::math::transformTypeMatch(type, helios::math::TransformType::Scale)) {
551 using mat4f = mat4<float>;
556 using mat4d = mat4<double>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.