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

◆ align

kyosu::align = eve::functor<align_t>
inlineconstexpr

Callable object computing an unitary quaternion value representing a rotation that align v0 to v1.

Return value An unitary quaternion value representing a rotation that align v0 to v1. If v0 or v01 is a nullvector the result is one as a quaternion.

Note
by default v0 and v1 are not assumed unitary (vectors of norm 1). If it is the case the decorator assume_unitary can be used.

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(std::span(v0), std::span(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, std::span(v0));
std::cout << " rotate_vec(q, v0) " << rv[0] << ", " << rv[1] << ", " << rv[2] << "\n";
return 0;
}
constexpr auto i
Computes the complex number in the chosen type.
Definition: i.hpp:69
constexpr auto align
Callable object computing an unitary quaternion value representing a rotation that align v0 to v1.
Definition: align.hpp:78
constexpr auto rotate_vec
Callable object rotating an vector using a quaternion.
Definition: rotate_vec.hpp:80

Header file

#include kyosu/module/quaternion.hpp>`

Callable Signatures

namespace kyosu
{
auto align(auto v1, auto v2) const noexcept;
auto align[assume_unitary](auto v1, auto v2) const noexcept;
}
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • v0: span of 3 elements
  • v1: span of 3 elements