Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
2440706b
Unverified
Commit
2440706b
authored
Apr 19, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup
parent
cf628fa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
40 deletions
+65
-40
test/unit-3d-test.cpp
+65
-40
No files found.
test/unit-3d-test.cpp
View file @
2440706b
...
...
@@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(m2q_1, *utf::tolerance(0.001f))
auto
sin
=
std
::
sin
(
a1
/
2
);
auto
cos
=
std
::
cos
(
a1
/
2
);
cif
::
quaternion
q
{
cos
,
0
,
0
,
sin
}
;
cif
::
quaternion
q
=
normalize
(
cif
::
quaternion
{
cos
,
0
,
0
,
sin
})
;
auto
pr
=
pts
[
0
];
pr
.
rotate
(
q
);
...
...
@@ -277,6 +277,11 @@ BOOST_AUTO_TEST_CASE(m2q_1, *utf::tolerance(0.001f))
BOOST_TEST
(
pr
.
m_y
==
pts
[
1
].
m_y
);
BOOST_TEST
(
pr
.
m_z
==
pts
[
1
].
m_z
);
auto
&&
[
angle_r
,
axis_r
]
=
cif
::
quaternion_to_angle_axis
(
q
);
std
::
cout
<<
angle_r
<<
std
::
endl
<<
axis_r
<<
std
::
endl
;
cif
::
matrix3x3
<
float
>
rot
;
rot
(
0
,
0
)
=
0
;
rot
(
0
,
1
)
=
-
1
;
...
...
@@ -293,64 +298,84 @@ BOOST_AUTO_TEST_CASE(m2q_1, *utf::tolerance(0.001f))
BOOST_TEST
(
pr
.
m_y
==
pts
[
1
].
m_y
);
BOOST_TEST
(
pr
.
m_z
==
pts
[
1
].
m_z
);
Eigen
::
Matrix3f
em2
;
em2
(
0
,
0
)
=
0
;
em2
(
0
,
1
)
=
-
1
;
em2
(
0
,
2
)
=
0
;
em2
(
1
,
0
)
=
1
;
em2
(
1
,
1
)
=
-
1
;
em2
(
1
,
2
)
=
0
;
em2
(
2
,
0
)
=
0
;
em2
(
2
,
1
)
=
0
;
em2
(
2
,
2
)
=
1
;
//
Eigen::Matrix3f em2;
//
em2(0, 0) = 0;
//
em2(0, 1) = -1;
//
em2(0, 2) = 0;
//
em2(1, 0) = 1;
//
em2(1, 1) = -1;
//
em2(1, 2) = 0;
//
em2(2, 0) = 0;
//
em2(2, 1) = 0;
//
em2(2, 2) = 1;
Eigen
::
EigenSolver
<
Eigen
::
Matrix3f
>
es
(
em2
);
//
Eigen::EigenSolver<Eigen::Matrix3f> es(em2);
auto
eev
=
es
.
eigenvalues
();
//
auto eev = es.eigenvalues();
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
{
if
(
std
::
abs
(
eev
[
i
].
real
()
-
1
)
>
0.01
)
continue
;
// for (size_t i = 0; i < 3; ++i)
// {
// if (std::abs(eev[i].real() - 1) > 0.01)
// continue;
// auto tr = em2(0, 0) + em2(1, 1) + em2(2, 2);
// auto a2 = std::acos((tr - 1) / 2.0f);
// BOOST_TEST(2 * std::cos(a2) + 1 == tr);
auto
tr
=
em2
(
0
,
0
)
+
em2
(
1
,
1
)
+
em2
(
2
,
2
);
auto
a2
=
std
::
acos
((
tr
-
1
)
/
2.0
f
);
BOOST_TEST
(
2
*
std
::
cos
(
a2
)
+
1
==
tr
);
// // Nice, but not working.
// Nice, but not working.
// // axis is:
// axis is:
// auto c = es.eigenvectors().col(i);
auto
c
=
es
.
eigenvectors
().
col
(
i
)
;
cif
::
point
axis
{
c
(
0
).
real
(),
c
(
1
).
real
(),
c
(
2
).
real
()
};
// // cif::point axis{ c(0).real(), c(1).real(), c(2).real() }
;
// // take line perpendicular to this axis
// take line perpendicular to this axis
// auto s2 = std::sin(a2 / 2);
// auto c2 = std::cos(a2 / 2);
// auto q2 = normalize(cif::quaternion{
// static_cast<float>(c2),
// static_cast<float>(s2 * c(0).real()),
// static_cast<float>(s2 * c(1).real()),
// static_cast<float>(s2 * c(2).real()) });
auto
s2
=
std
::
sin
(
a2
/
2
);
auto
c2
=
std
::
cos
(
a2
/
2
);
// auto &&[angle_r2, axis_r2] = cif::quaternion_to_angle_axis(q2);
// std::cout << angle_r2 << std::endl
// << axis_r2 << std::endl;
auto
q2
=
normalize
(
cif
::
quaternion
{
static_cast
<
float
>
(
c2
),
static_cast
<
float
>
(
s2
*
c
(
0
).
real
()),
static_cast
<
float
>
(
s2
*
c
(
1
).
real
()),
static_cast
<
float
>
(
s2
*
c
(
2
).
real
())
});
pr
=
pts
[
0
];
pr
.
rotate
(
q2
);
BOOST_TEST
(
pr
.
m_x
==
pts
[
1
].
m_x
);
BOOST_TEST
(
pr
.
m_y
==
pts
[
1
].
m_y
);
BOOST_TEST
(
pr
.
m_z
==
pts
[
1
].
m_z
);
// pr = pts[0];
// pr.rotate(q2);
// BOOST_TEST(pr.m_x == pts[1].m_x);
// BOOST_TEST(pr.m_y == pts[1].m_y);
// BOOST_TEST(pr.m_z == pts[1].m_z);
// break;
break
;
// }
}
cif
::
point
t1
{
1
,
1
,
1
};
cif
::
point
t2
=
rot
*
t1
;
float
a2
=
std
::
acos
(
dot_product
(
t1
,
t2
)
/
(
t1
.
length
()
*
t2
.
length
()));
auto
sin2
=
std
::
sin
(
a2
/
2
);
auto
cos2
=
std
::
cos
(
a2
/
2
);
cif
::
quaternion
q2
=
normalize
(
cif
::
quaternion
{
cos2
,
0
,
0
,
sin2
});
pr
=
pts
[
0
];
pr
.
rotate
(
q2
);
BOOST_TEST
(
pr
.
m_x
==
pts
[
1
].
m_x
);
BOOST_TEST
(
pr
.
m_y
==
pts
[
1
].
m_y
);
BOOST_TEST
(
pr
.
m_z
==
pts
[
1
].
m_z
);
auto
&&
[
angle_r2
,
axis_r2
]
=
cif
::
quaternion_to_angle_axis
(
q
);
std
::
cout
<<
angle_r2
<<
std
::
endl
<<
axis_r2
<<
std
::
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment