sead
Loading...
Searching...
No Matches
seadQuatCalcCommon.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <math/seadMathCalcCommon.h>
4#include <math/seadQuat.h>
5
6namespace sead {
7
8template <typename T>
9inline void
11{
12 q = Quat<T>::unit;
13}
14
15template <typename T>
16bool QuatCalcCommon<T>::makeVectorRotation(Base& q, const Vec3& from, const Vec3& to)
17{
18 Vec3 cross;
19 Vector3CalcCommon<T>::cross(cross, from, to);
20 const T dot = Vector3CalcCommon<T>::dot(from, to) + 1;
21
22 if (dot <= MathCalcCommon<T>::epsilon())
23 {
25 return false;
26 }
27 else
28 {
29 T v1 = MathCalcCommon<T>::sqrt(2 * dot);
30 T v2 = 1 / v1;
31 set(q, v1 * 0.5f,
32 cross.x * v2, cross.y * v2, cross.z * v2);
33 }
34
35 return true;
36}
37
38template <typename T>
39inline void
40QuatCalcCommon<T>::set(Base& q, T w, T x, T y, T z)
41{
42 q.w = w;
43 q.x = x;
44 q.y = y;
45 q.z = z;
46}
47
48} // namespace sead
Definition seadMathCalcCommon.h:12
Definition seadQuatCalcCommon.h:10
Policies< T >::Vec3Base Vec3
Definition seadQuatCalcCommon.h:13
static void makeUnit(Base &q)
Definition seadQuatCalcCommon.hpp:10
static void set(Base &q, T w, T x, T y, T z)
Definition seadQuatCalcCommon.hpp:40
Policies< T >::QuatBase Base
Definition seadQuatCalcCommon.h:12
static bool makeVectorRotation(Base &q, const Vec3 &from, const Vec3 &to)
Definition seadQuatCalcCommon.hpp:16
Definition seadQuat.h:10
Definition seadVectorCalcCommon.h:44
Definition seadAssert.h:44