mat4.ixx File
4x4 matrix type and utilities. More...
Included Headers
#include <cassert>
#include <functional>
#include <helios.math.types:vec4>
#include <helios.math.concepts>
#include <helios.math.TransformType>
Namespaces Index
| namespace | helios |
| namespace | math |
|
Mathematical operations and types. More... | |
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:
20export namespace helios::math {
105 return mat4<T>(1);
130 constexpr const T& operator()(const size_t row, const size_t col) const {
157 constexpr T& operator()(const size_t row, const size_t col) {
185 const auto* leftPtr = value_ptr(*this);
186 const auto* rgtPtr = value_ptr(rgt);
206 constexpr bool operator==(const mat4<T>& rgt) const {
208 const auto* leftPtr = value_ptr(*this);
209 const auto* rgtPtr = value_ptr(rgt);
230 mat4<T> A{};
257 return vec4<T>{
277 helios::math::mat4<T> transpose() const noexcept {
279 return helios::math::mat4<T>{
293 helios::math::vec4<T> column(unsigned int i) const noexcept {
296 return helios::math::vec4<T>{
308 constexpr helios::math::mat4<T> inverse() const noexcept {
311 const auto a = column(0).toVec3();
312 const auto b = column(1).toVec3();
313 const auto c = column(2).toVec3();
314 const auto d = column(3).toVec3();
321 auto s = helios::math::cross(a, b);
322 auto t = helios::math::cross(c, d);
326 T invDet = static_cast<T>(1) / (helios::math::dot(s, v) + helios::math::dot(t, u));
333 auto r0 = (helios::math::cross(b, v)) + t*y;
334 auto r1 = (helios::math::cross(v, a)) - t*x;
335 auto r2 = (helios::math::cross(d, u)) + s*w;
336 auto r3 = (helios::math::cross(u, c)) - s*z;
338 return helios::math::mat4<T>{
339 r0[0], r0[1], r0[2], -helios::math::dot(b, t),
340 r1[0], r1[1], r1[2], helios::math::dot(a, t),
341 r2[0], r2[1], r2[2], -helios::math::dot(d, s),
342 r3[0], r3[1], r3[2], helios::math::dot(c, s)
354 helios::math::vec3<T> translation() const noexcept {
356 return helios::math::vec3<T>{
371 helios::math::mat4<T> withTranslation(helios::math::vec3<T> v) const noexcept {
373 return helios::math::mat4<T>{
392 helios::math::mat4<T> withScaling(helios::math::vec3<T> v) const noexcept {
394 return helios::math::mat4<T>{
413 helios::math::mat4<T> withTranslation(helios::math::vec4<T> v) const noexcept {
415 return helios::math::mat4<T>{
449 helios::math::mat4<T> decompose(const helios::math::TransformType type) const noexcept {
451 if (type == helios::math::TransformType::All) {
455 auto id = identity();
456 if (helios::math::transformTypeMatch(type, helios::math::TransformType::Translation)) {
463 && helios::math::transformTypeMatch(type, helios::math::TransformType::Scale)) {
469 const auto bx = vec3<T>(m(0, 0), m(1, 0), m(2, 0));
470 const auto by = vec3<T>(m(0, 1), m(1, 1), m(2, 1));
471 const auto bz = vec3<T>(m(0, 2), m(1, 2), m(2, 2));
477 if (helios::math::transformTypeMatch(type, helios::math::TransformType::Rotation)) {
485 } else if (helios::math::transformTypeMatch(type, helios::math::TransformType::Scale)) {
534 using mat4f = mat4<float>;
539 using mat4d = mat4<double>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.