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

◆ to_rotation_matrix

kyosu::to_rotation_matrix = eve::functor<to_rotation_matrix_t>
inlineconstexpr

Callable object computing a quaternion from its to_rotation_matrix representation.

This function build rotation_matrix angles from a quaternion.

Header file

#include kyosu/quaternion.hpp>`

Callable Signatures

namespace eve
{
auto to_rotation_matrix(auto q) const noexcept; //1
auto to_rotation_matrix[assume_unitary](auto q) const noexcept; //2
}
constexpr auto to_rotation_matrix
Callable object computing a quaternion from its to_rotation_matrix representation.
Definition: to_rotation_matrix.hpp:122

Parameters

  • q quaternion representing the rotation

Return value

  1. compute the rotation matrix associated to the quaternion.
  2. with assume_unitary, assumes that q is already normalized

if T is the element type of q, returns an std::array<std::array<T, 3>, 3> containing the 9 coefficients of the rotation matrix

Note
use this function if you really need the rotation matrix, but to rotate vectors prefer the function rot_vec that directly uses the quaternion.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
std::cout << "Quaternion: "<< "\n";
q_t q0(1, 5, 2, 3);
auto m = to_rotation_matrix(q0);
std::cout << "q0 = " << q0 << std::endl;
std::cout << "to_rotation_matrix(q0) = \n";
for(int i=0; i <3 ; ++i)
{
std::cout << " ";
for(int j=0; j < 2 ; ++j)
{
std::cout << m[i][j] << ", ";
}
std::cout << m[i][2] << "\n";
}
return 0;
}
constexpr auto j
Computes the complex number j i.e. quaternion(0, 0, 1, 0) in the chosen type.
Definition: j.hpp:74
constexpr auto i
Computes the complex number in the chosen type.
Definition: i.hpp:69
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:24
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27