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

◆ from_angle_axis

kyosu::from_angle_axis = {}
inlineconstexpr

Callable object computing an an unitary quaternion from an angle value and a 3 dimensionnal axis vector.

Defined in header

#include kyosu/module/quaternion.hpp>`

Callable Signatures

namespace kyosu
{
auto from_angle_axis(auto angle, auto axis, auto norming = normalize) const noexcept;
}
constexpr tags::callable_from_angle_axis from_angle_axis
Callable object computing an an unitary quaternion from an angle value and a 3 dimensionnal axis vect...
Definition: from_angle_axis.hpp:115
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • angle: rotation angle in radian
  • axis: rotation axis given by an std::span of dimension 3.
  • normalize: can be assume_normalized or normalize.
    • In the second case the axis is normalized before use.
    • if the axis is already normalized using assume_normalized is more efficient, but the result is u.b. if it is not the case.
    • if the axis is null the axis is normalized as (1, 0, 0).

Return value

the quaternion value representing the rotation.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <array>
#include <iostream>
int main()
{
auto theta = eve::pio_3(eve::as<double>());
std::array<double, 3> ax{1., 2., 3.};
std::cout << " <- theta = " << theta << std::endl;
std::cout << " <- axis = (" << ax[0] << ", " << ax[1] << ", " << ax[2] << ")" << std::endl;
auto q = kyosu::from_angle_axis(theta, ax);
std::cout << " -> " << kyosu::from_angle_axis(theta, ax) << "\n";
auto [aa, axx] = kyosu::to_angle_axis(q);
std::cout << " ->theta = " << aa << std::endl;
std::cout << " -> axis = (" << axx[0] << ", " << axx[1] << ", " << axx[2] << ")" << std::endl;
std::array<double, 3> azz{0., 0., 0.};
std::cout << kyosu::from_angle_axis(theta, azz) << std::endl;
return 0;
}
constexpr tags::callable_to_angle_axis to_angle_axis
Callable object computing the angle and axis coordinates from a quaternion.
Definition: to_angle_axis.hpp:85
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