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

◆ align

kyosu::align = {}
inlineconstexpr

Callable object computing a quaternion from its angle_axis representation.

This function build 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 align(auto v1, auto v2, auto norming = normalize) const noexcept;
}
constexpr tags::callable_align align
Callable object computing a quaternion from its angle_axis representation.
Definition: align.hpp:118
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • v0: span of 3 elements
  • v1: span of 3 elements
  • normalize: can be assume_normalized or normalize. In the second case axis is normalized. if axis is already normalized use of assume_normalized is more efficient.

Return value

An unitary quaternion value representing a rotation that align v0 to v1.

If v0 or v1 is a nullvector the result is UB

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::align;
auto norm = [](auto &v){
auto n = eve::hypot(v[0], v[1], v[2]);
for(int i=0; i <= 2; ++i) v[i]/= n;
};
std::array<double, 3> v0{-1.0, 5.0, 4.0};
std::array<double, 3> v1{ 1.5, 2.0, -3.0};
norm(v0);
norm(v1);
auto q = kyosu::align(v0, v1);
std::cout << " v0 " << v0[0] << ", " << v0[1] << ", " << v0[2] << "\n";
std::cout << " v1 " << v1[0] << ", " << v1[1] << ", " << v1[2] << "\n";
std::cout << " q " << q << std::endl;
auto rv = kyosu::rotate_vec(q, v0);
std::cout << " rotate_vec(q, v0) " << rv[0] << ", " << rv[1] << ", " << rv[2] << "\n";
return 0;
}
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_rotate_vec rotate_vec
Callable object rotating an vector using a quaternion.
Definition: rotate_vec.hpp:105