19#ifndef FENNEC_MATH_EXT_TRANSFORM_H
20#define FENNEC_MATH_EXT_TRANSFORM_H
25#include <fennec/math/ext/quaternion.h>
34template<
typename genType>
35constexpr mat<genType, 3, 3> translation(
const vector<genType, 0, 1>& x) {
36 return mat<genType, 3, 3>(
47template<
typename genType>
48constexpr mat<genType, 4, 4> translation(
const vector<genType, 0, 1, 2>& x) {
49 return mat<genType, 4, 4>(
61template<
typename genType>
62constexpr mat<genType, 3, 3> scaling(
const vector<genType, 0, 1>& x) {
63 return mat<genType, 3, 3>(
74template<
typename genType>
75constexpr mat<genType, 4, 4> scaling(
const vector<genType, 0, 1, 2>& x) {
76 return mat<genType, 4, 4>(
84template<
typename genType>
85constexpr mat<genType, 3, 3> shear(
const vector<genType, 0, 1>& x) {
86 return mat<genType, 3, 3>(
97template<
typename genType>
98constexpr mat<genType, 3, 3> rotation(
const genType a) {
105 return mat<genType, 3, 3>(
117template<
typename genType>
118constexpr mat<genType, 4, 4> rotation(
const vector<genType, 0, 1, 2>& A, genType a) {
126 const vector<genType, 0, 1, 2> u = (fennec::one<genType>() - c) * A;
127 const vector<genType, 0, 1, 2> v = s * A;
130 return mat<genType, 4, 4>(
131 A.x * u.x + c, A.x * u.y + v.z, A.x * u.z - v.y, 0,
132 A.x * u.y - v.z, A.y * u.y + c, A.y * u.z + v.x, 0,
133 A.x * u.z + v.y, A.y * u.z - v.x, A.z * u.z + c, 0,
159template<
typename genType, rotation_ axis>
160constexpr mat<genType, 4, 4> rotation(genType a) {
168 if constexpr(axis == rotation_x) {
169 return mat<genType, 4, 4>(
176 else if constexpr(axis == rotation_y) {
177 return mat<genType, 4, 4>(
184 else if constexpr(axis == rotation_z) {
185 return mat<genType, 4, 4>(
193 return mat<genType, 4, 4>();
213template<
typename genType, order_ order = order_zxy>
214constexpr mat<genType, 4, 4> rotation(
const vector<genType, 0, 1, 2>& E) {
226 if constexpr(order == order_xyz) {
227 return mat<genType, 4, 4>(
228 cb*cg, -cg*sg, sb, 0,
229 ca*sg + cg*sa*sb, ca*cg - sa*sb*sg, -ca*sa, 0,
230 sa*sg - ca*cg*sb, ca*sb*sg + cg*sa, ca*cb, 0,
233 }
else if constexpr(order == order_xzy) {
234 return mat<genType, 4, 4>(
235 cb*cg, -sg, cg*sb, 0,
236 ca*cb*sg + sa*sb, ca*cg, cb*sa*sg - ca*sb, 0,
237 cb*sa*sg - ca*sb, cg*sa, ca*cb + sa*sb*sg, 0,
240 }
else if constexpr(order == order_yxz) {
241 return mat<genType, 4, 4>(
242 cb*cg + sa*sb*sg, cg*sa*sb - cb*sg, ca*sb, 0,
243 ca*sg, ca*cg, -sa, 0,
244 cb*sa*sg - cg*sb, cb*cg*sa + sb*sg, ca*cb, 0,
247 }
else if constexpr(order == order_yzx) {
248 return mat<genType, 4, 4>(
249 cb*cg, sa*sb - ca*cb*sg, ca*sb + cb*sa*sg, 0,
250 sg, ca*cg, -cg*sa, 0,
251 -cg*sb, ca*sb*sg + cb*sa, ca*cb - sa*sb*sg, 0,
254 }
else if constexpr(order == order_zxy) {
255 return mat<genType, 4, 4>(
256 cb*cg - sa*sb*sg, -ca*sg, cb*sa*sg + cg*sb, 0,
257 cb*sg + cg*sa*sb, ca*cg, sb*sg - cb*cg*sa, 0,
258 -ca*sb, sa, ca*cb, 0,
261 }
else if constexpr(order == order_zyx) {
262 return mat<genType, 4, 4>(
263 cb*cg, cg*sa*sb - ca*sg, ca*cg*sb + sa*sg, 0,
264 cb*sg, ca*cg + sa*sb*sg, ca*sb*sg - cg*sa, 0,
265 -sb, cb*sa, ca*cb, 0,
270 return mat<genType, 4, 4>();
constexpr genType sin(genType x)
The standard trigonometric sine.
Definition trigonometric.h:204
constexpr genType cos(genType x)
The Standard Trigonometric Cosine.
Definition trigonometric.h:218