Skip to content

Commit

Permalink
align.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Sep 28, 2023
1 parent 950b220 commit 3df66f2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/doc/align.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#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;
}

0 comments on commit 3df66f2

Please sign in to comment.