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

◆ from_angle_axis

kyosu::from_angle_axis = eve::functor<from_angle_axis_t>
inlineconstexpr

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

Header file

#include kyosu/module/quaternion.hpp>`

Callable Signatures

namespace kyosu
{
auto from_angle_axis(auto angle, auto axis) const noexcept;
auto from_angle_axis[assume_unitary](auto angle, auto axis) const noexcept;
}
constexpr auto from_angle_axis
Callable object computing an an unitary quaternion from an angle value and a 3 dimensional axis vecto...
Definition: from_angle_axis.hpp:76
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • angle: rotation angle in radian
  • axis: rotation axis given by an std::span of dimension 3.

Return value

  1. the quaternion value representing the rotation. (if the axis is null the axis is normalized as (1, 0, 0)).
  2. with assume_unitary the axis is NOT normalized before use, but the result is undefined if it is not the case.

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, std::span(ax));
std::cout << " -> " << kyosu::from_angle_axis(theta, std::span(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, std::span(azz)) << std::endl;
return 0;
}
constexpr auto to_angle_axis
Callable object computing the angle and axis coordinates from a quaternion.
Definition: to_angle_axis.hpp:74
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