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

◆ rotate_vec

kyosu::rotate_vec = eve::functor<rotate_vec_t>
inlineconstexpr

Callable object rotating an \(\mathbb{R}^3\) vector using a quaternion.

Header file

#include kyosu/quaternion.hpp>`

Callable Signatures

namespace eve
{
auto rotate_vec(auto q, auto v) const noexcept;
auto rotate_vec[assume_unitary](auto q, auto v) const noexcept
}
constexpr auto rotate_vec
Callable object rotating an vector using a quaternion.
Definition: rotate_vec.hpp:80

Parameters

q: quaternion value defining the rotation. v: span of 3 elements to rotate.

Return value

  1. the span rotated by q
  2. with assume_unitary, assumes that q is already normalized

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
auto theta = eve::pio_3(eve::as<double>());
std::array<double, 3> ax{1., 2., 3.};
std::array<double, 3> v{ 1.5, 2.0, -3.0};
auto q = kyosu::from_angle_axis(theta, std::span(ax));
std::cout << " v " << v[0] << ", " << v[1] << ", " << v[2] << ")\n";
std::cout << " q " << q << std::endl;
auto rv = kyosu::rotate_vec(q, std::span<double, 3>(v));
std::cout << " rotate_vec(q, v) " << " -> (" << rv[0] << ", " << rv[1] << ", " << rv[2] << ")\n";
return 0;
}
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