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

◆ from_rotation_matrix

kyosu::from_rotation_matrix = eve::functor<from_rotation_matrix_t>
inlineconstexpr

Callable object computing a quaternion from its rotation_matrix representation.

This function returns a quaternion associated to the input rotation matrix m. If m is not a proper 3x3 rotation matrix (i.e an orthogonal matrix with determinant 1) the result is undefined.

Header file

#include kyosu/quaternion.hpp>`

Callable Signatures

namespace eve
{
template < typename M >
auto from_rotation_matrix(auto m) const noexcept
}
constexpr auto from_rotation_matrix
Callable object computing a quaternion from its rotation_matrix representation.
Definition: from_rotation_matrix.hpp:93

Parameters

  • m the rotation matrix. The actual implementation assumes that m[i][j] will return the ith line and jth column element of the matrix (indices starting from 0).

    The computation method is inspired from the article: "Accurate Computation of Quaternions from Rotation Matrices", by Soheil Sarabandi and Federico Thomas Institut de Robotica i Informatica Industrial (CSIC-UPC) Llorens Artigas 4-6, 08028 Barcelona, Spain.

Return value

an unitary quaternion representing the rotation

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
std::cout << "Quaternion: "<< "\n";
q_t q0(1, 5, 2, 3);
q0 = kyosu::sign(q0); //normalization is optional
auto m = to_rotation_matrix(q0);
std::cout << "q0 = " << q0 << std::endl;
std::cout << "m = 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";
}
std::cout << "from_rotation_matrix(m) = " << from_rotation_matrix(m) << std::endl;
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
constexpr auto sign
Computes tne normalized value z/abs(z) if z is not zero else 0.
Definition: sign.hpp:63
constexpr auto to_rotation_matrix
Callable object computing a quaternion from its to_rotation_matrix representation.
Definition: to_rotation_matrix.hpp:122
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