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