-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_euclidean.cpp
72 lines (64 loc) · 1.7 KB
/
test_euclidean.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/** written by olaf booij
* public domain */
#include<iostream>
#include<array>
#include<Eigen/Core>
#include"liespline.hpp"
#undef NDEBUG
#include<cassert>
#define NDEBUG
struct eu
{
static auto log(const auto& a){ return a; }
static auto exp(const auto& a){ return a; }
static auto place(const auto& a, const auto& b){ return b - a; }
static auto prod(const auto& a){ return a; }
static auto prod(const auto& a, const auto& b, const auto&... t){ return a + prod(b, t...); }
};
int main()
{
using namespace liespline;
auto close = [](auto a, auto b){return fabs(a - b) < 1e-7;};
{
assert(close(eu::log(1.2), 1.2));
assert(close(eu::exp(1.2), 1.2));
assert(close(eu::prod(1.2, 1.3), 2.5));
assert(close(eu::prod(1.2, 1.3, 0.3), 2.8));
}
{
std::array T{1., 1., 1., 1.};
assert(close(interpolate<eu>(T, 1.2), 1.));
}
{
std::array T{0., 1., 2., 3.};
assert(close(interpolate<eu>(T, .3), 1.3));
}
{
std::array T{0., 0., 0., 10.};
assert(interpolate<eu>(T, .1) > 0.);
}
{
std::array T{10., 0., 0., 0.};
assert(interpolate<eu>(T, .1) > 0.);
assert(interpolate<eu>(T, .6) > 0.);
}
{
std::array T{0., 2., 2., 3., 5., 6.};
assert(close(interpolate<eu>(T.begin() + 0, 1),
interpolate<eu>(T.begin() + 1, 0)));
assert(close(interpolate<eu>(T.begin() + 1, 1),
interpolate<eu>(T.begin() + 2, 0)));
}
{
std::array<Eigen::Vector2d, 4> T{{{1., 1}, {1., -1.}, {-1., -1.}, {-1., 1.}}};
for(double u = 0; u < 1; u += .1)
{
const auto T_u = interpolate<eu>(T, u);
assert(T_u(0) < 1.);
assert(T_u(0) > -1.);
assert(T_u(1) < 0);
assert(T_u(1) > -1.);
}
}
return 0;
}