quat.ixx File
Quaternion type for floating-point scalar types. More...
Included Headers
#include <cmath>
#include <concepts>
#include <helios.math.types:mat4>
Namespaces Index
| namespace | helios |
| namespace | math |
Classes Index
| struct | Intrinsic |
|
Marker tag for intrinsic Euler-angle composition. More... | |
| struct | Extrinsic |
|
Marker tag for extrinsic Euler-angle composition. More... | |
| class | quat<T> |
|
Quaternion with scalar part w and vector part v. More... | |
Description
Quaternion type for floating-point scalar types.
File Listing
The file content with the documentation metadata removed is:
17export namespace helios::math {
40 vec3<T> v_;
56 static constexpr quat<T> fromEulerAngles(const T xAngle, const T yAngle, const T zAngle) noexcept {
58 const auto x = vec3<T>{static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)};
59 const auto y = vec3<T>{static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)};
60 const auto z = vec3<T>{static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)};
63 return (fromAxisAngle(x, xAngle) * fromAxisAngle(y, yAngle) * fromAxisAngle(z, zAngle)).normalized();
65 return (fromAxisAngle(z, zAngle) * fromAxisAngle(y, yAngle) * fromAxisAngle(x, xAngle)).normalized();
76 return quat<T>{vec3<T>{static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)}, static_cast<T>(1)};
86 static constexpr quat<T> fromAxisAngle(const helios::math::vec3<T> v, const T angle) noexcept {
90 return quat<T>{
91 std::sin(rad) * v.normalize(),
128 return quat<T>{v_ * static_cast<T>(-1), w_};
166 [[nodiscard]] constexpr quat<T> normalized() const noexcept {
167 const auto l = length();
168 return quat<T>{v_ * (static_cast<T>(1) / l), w_ / l};
176 [[nodiscard]] constexpr mat4<T> rotationMatrix() const noexcept {
178 const auto q_norm = normalized();
179 const auto v = q_norm.v();
180 const auto w = q_norm.w();
192 return mat4<T>{
223 const auto q_norm = normalized();
226 return (q_norm * other * q_norm.conjugate()).v() ;
235 using quatf = quat<float>;
240 using quatd = quat<double>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.