kyosu v0.1.0
Complex Without Complexes
Loading...
Searching...
No Matches

◆ to_euler

auto kyosu::to_euler = eve::functor<to_euler_t>
inlineconstexpr

Callable object computing euler angles from a quaternion.

This function build euler angles from a quaternion. Template parameters I, J, K of type int are used to choose the euler order.

for instance I = 3, J = 2, K = 3 choose the ZYZ sequence. the values of I, J, and K must be in {1, 2, 3} and satisfy I != J && J != K.

Header file

#include kyosu/quaternion.hpp>`

Callable Signatures

namespace eve
{
template < int I, int J, int K >
auto to_euler(auto q, axis<I> const & a1, axis<J> const & a2, axis<K> const & a3) noexcept
requires(I != J && J != K) //1
template < int I, int J, int K >
auto to_euler[extrinsic](auto q, axis<I> const & a1, axis<J> const & a2, axis<K> const & a3) noexcept //1
requires(I != J && J != K)
template < int I, int J, int K >
auto to_euler[intrinsic](auto q, axis<I> const & a1, axis<J> const & a2, axis<K> const & a3) noexcept //2
requires(I != J && J != K)
template < int I, int J, int K >
auto to_euler[radpi][/*all previous options*/](/*all previous overloads*/) noexcept
requires(I != J && J != K)
}
constexpr auto to_euler
Callable object computing euler angles from a quaternion.
Definition to_euler.hpp:193

Parameters

  • q the rotation quaternion (not necesseraly normalized)
  • a1, a2, a3: the axis parameters to be chosen between X_, Y_, Z_ (two consecutive axes cannot be the same)
  • depending of the euler order

Template parameters

  • I, J, K: actual parameters can be chosen between axis values X_, Y_, Z_ from which I, J and K are deduced

Return value

  1. kumi tuple of the three euler angles in radian (or in \(\pi\) multiples if the option radpi is used). In case of singularity the first angle is 0. extrinsic rotation order is used
  2. Same but in the intrinsic way

External references

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using kyosu::average;
using e_t = float;
using we_t = eve::wide<float, eve::fixed<2>>;
using wc_t = eve::wide<kyosu::complex_t<float>, eve::fixed<2>>;
using wq_t = eve::wide<kyosu::quaternion_t<float>, eve::fixed<2>>;
std::cout << "Real: " << "\n";
e_t e0(1);
e_t e1(2);
std::cout << e0 << ", " << e1 << " -> " << average(e0, e1) << "\n";
std::cout << e0 << ", " << e0 << " -> " << average(e0, e0) << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << ", " << we1 << " -> " << average(we0, we1) << "\n";
std::cout << "Complex: " << "\n";
c_t c0(1, 5);
c_t c1(5, 9);
std::cout << c0 << ", " << c1 << " -> " << average(c0, c1) << "\n";
std::cout << c0 << ", " << c0 << " -> " << average(c0, c0) << "\n";
wc_t wc0(c0, c1);
wc_t wc1(c1, c1);
std::cout << wc0 << ", " << wc1 << " -> " << average(wc0, wc1) << "\n";
std::cout << "Quaternion: " << "\n";
q_t q0(1, 5, 2, 3);
q_t q1(5, 9, 6, 7);
std::cout << q0 << ", " << q1 << " -> " << average(q0, q1) << "\n";
std::cout << q0 << ", " << q0 << " -> " << average(q0, q0) << "\n";
wq_t wq0(q0, q1);
wq_t wq1(q1, q1);
std::cout << wq0 << ", " << wq1 << " -> " << average(wq0, wq1) << "\n";
std::cout << "Mixed: " << "\n";
std::cout << kyosu::average(c0, q1) << std::endl;
std::cout << kyosu::average(e0, q1) << std::endl;
std::cout << kyosu::average(c0, wq1) << std::endl;
std::cout << kyosu::average(we0, q1) << std::endl;
return 0;
}
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition complex.hpp:27
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition quaternion.hpp:24