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

◆ from_rotation_matrix

kyosu::from_rotation_matrix = {}
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 rotation 3x3 rotation matrix (i.e an orthogonal matrix with determinant 1) the result is undefined.

Defined in header

#include eve/module/quaternion.hpp>`

Callable Signatures

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

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 tags::callable_sign sign
Computes tne normalized value z/abs(z) if z is not zero else 0.
Definition: sign.hpp:75
constexpr tags::callable_i i
Computes the complex number cinf i.e. complex(nan, inf) in the chosen type.
Definition: i.hpp:77
constexpr tags::callable_to_rotation_matrix to_rotation_matrix
Callable object computing a quaternion from its to_rotation_matrix representation.
Definition: to_rotation_matrix.hpp:115
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:27
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27