summaryrefslogtreecommitdiffstats
path: root/depedencies/include/glm/gtx/rotate_normalized_axis.inl
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
commite62817b8252974b8a98393275874ee303840bf13 (patch)
tree4565935f06e369f4a84410b0c098958e07a750c7 /depedencies/include/glm/gtx/rotate_normalized_axis.inl
parent2017-05-10 (diff)
downloadAltCraft-e62817b8252974b8a98393275874ee303840bf13.tar
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.gz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.bz2
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.lz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.xz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.zst
AltCraft-e62817b8252974b8a98393275874ee303840bf13.zip
Diffstat (limited to 'depedencies/include/glm/gtx/rotate_normalized_axis.inl')
-rw-r--r--depedencies/include/glm/gtx/rotate_normalized_axis.inl59
1 files changed, 59 insertions, 0 deletions
diff --git a/depedencies/include/glm/gtx/rotate_normalized_axis.inl b/depedencies/include/glm/gtx/rotate_normalized_axis.inl
new file mode 100644
index 0000000..dc1b1a8
--- /dev/null
+++ b/depedencies/include/glm/gtx/rotate_normalized_axis.inl
@@ -0,0 +1,59 @@
+/// @ref gtx_rotate_normalized_axis
+/// @file glm/gtx/rotate_normalized_axis.inl
+
+namespace glm
+{
+ template <typename T, precision P>
+ GLM_FUNC_QUALIFIER tmat4x4<T, P> rotateNormalizedAxis
+ (
+ tmat4x4<T, P> const & m,
+ T const & angle,
+ tvec3<T, P> const & v
+ )
+ {
+ T const a = angle;
+ T const c = cos(a);
+ T const s = sin(a);
+
+ tvec3<T, P> const axis(v);
+
+ tvec3<T, P> const temp((static_cast<T>(1) - c) * axis);
+
+ tmat4x4<T, P> Rotate(uninitialize);
+ Rotate[0][0] = c + temp[0] * axis[0];
+ Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
+ Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
+
+ Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
+ Rotate[1][1] = c + temp[1] * axis[1];
+ Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
+
+ Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
+ Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
+ Rotate[2][2] = c + temp[2] * axis[2];
+
+ tmat4x4<T, P> Result(uninitialize);
+ Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
+ Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
+ Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
+ Result[3] = m[3];
+ return Result;
+ }
+
+ template <typename T, precision P>
+ GLM_FUNC_QUALIFIER tquat<T, P> rotateNormalizedAxis
+ (
+ tquat<T, P> const & q,
+ T const & angle,
+ tvec3<T, P> const & v
+ )
+ {
+ tvec3<T, P> const Tmp(v);
+
+ T const AngleRad(angle);
+ T const Sin = sin(AngleRad * T(0.5));
+
+ return q * tquat<T, P>(cos(AngleRad * static_cast<T>(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
+ //return gtc::quaternion::cross(q, tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
+ }
+}//namespace glm