Add quaternion exponential
This commit is contained in:
parent
451b4c1e66
commit
44db0e8fee
1 changed files with 11 additions and 0 deletions
|
|
@ -199,6 +199,17 @@ namespace psemek::geom
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
quaternion<T> exp(quaternion<T> const & q)
|
||||
{
|
||||
auto v = vector{q[0], q[1], q[2]};
|
||||
auto l = length(v);
|
||||
|
||||
auto s = sin_over_x(l);
|
||||
|
||||
return std::exp(q[3]) * quaternion<T>({v[0] * s, v[1] * s, v[2] * s, std::cos(l)});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream & operator << (std::ostream & os, quaternion<T> const & q)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue