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

◆ rotate_vec

kyosu::rotate_vec = {}
inlineconstexpr

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

Defined in header

#include eve/module/quaternion.hpp>`

Callable Signatures

namespace eve
{
auto rotate_vec(auto q, auto v) const noexcept;
}
constexpr tags::callable_rotate_vec rotate_vec
Callable object rotating an vector using a quaternion.
Definition: rotate_vec.hpp:105

Parameters

q: quaternion value defining the rotation.

v: span of 3 elements to rotate.

Return value

the span rotated by q


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, 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 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