-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtest_so2.cpp
70 lines (57 loc) · 1.62 KB
/
test_so2.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
// Copyright (C) 2021-2022 Petter Nilsson. MIT License.
#include <gtest/gtest.h>
#include "smooth/so2.hpp"
#include "smooth/so3.hpp"
TEST(SO2, Angle)
{
for (auto i = 0; i != 5; ++i) {
const auto g1 = smooth::SO2d::Random();
const auto g2 = smooth::SO2d::Random();
{
smooth::SO2d g_prod(g1.angle() + g2.angle());
ASSERT_TRUE(g_prod.isApprox(g1 * g2));
ASSERT_LE(g1.angle(), M_PI);
ASSERT_GE(g1.angle(), -M_PI);
}
{
smooth::SO2d g_prod(g1.angle_cw() + g2.angle_cw());
ASSERT_TRUE(g_prod.isApprox(g1 * g2));
ASSERT_LE(g1.angle_cw(), 0);
ASSERT_GE(g1.angle_cw(), -2. * M_PI);
}
{
smooth::SO2d g_prod(g1.angle_ccw() + g2.angle_ccw());
ASSERT_TRUE(g_prod.isApprox(g1 * g2));
ASSERT_LE(g1.angle_ccw(), 2. * M_PI);
ASSERT_GE(g1.angle_ccw(), 0);
}
}
}
TEST(SO2, Complex)
{
for (auto i = 0; i != 5; ++i) {
const auto g1 = smooth::SO2d::Random();
const auto g2 = smooth::SO2d::Random();
smooth::SO2d g_prod(g1.u1() * g2.u1());
ASSERT_TRUE(g_prod.isApprox(g1 * g2));
}
}
TEST(SO2, Action)
{
for (auto i = 0; i != 5; ++i) {
const auto g1 = smooth::SO2d::Random();
auto ex_rot = g1 * Eigen::Vector2d::UnitX();
auto ey_rot = g1 * Eigen::Vector2d::UnitY();
ASSERT_TRUE(ex_rot.isApprox(g1.matrix().col(0)));
ASSERT_TRUE(ey_rot.isApprox(g1.matrix().col(1)));
}
}
TEST(SO2, LiftProject)
{
for (auto i = 0u; i != 5; ++i) {
const smooth::SO2d g = smooth::SO2d::Random();
const auto so3 = g.lift_so3();
const auto so2 = so3.project_so2();
ASSERT_TRUE(so2.isApprox(g, 1e-6));
}
}