Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
43771ae7
Commit
43771ae7
authored
2 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add test for simox::aabb::is_colliding()
parent
2d74d6aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SimoxUtility/tests/shapes/AxisAlignedBoundingBoxTest.cpp
+43
-7
43 additions, 7 deletions
SimoxUtility/tests/shapes/AxisAlignedBoundingBoxTest.cpp
with
43 additions
and
7 deletions
SimoxUtility/tests/shapes/AxisAlignedBoundingBoxTest.cpp
+
43
−
7
View file @
43771ae7
...
...
@@ -4,10 +4,10 @@
* @copyright 2019 Raphael Grimm
*/
#define BOOST_TEST_MODULE SimoxUtility
/
shapes
/Oriented
BoxTest
#define BOOST_TEST_MODULE SimoxUtility
/
shapes
/ AxisAlignedBounding
BoxTest
#include
<random>
#include
<iostream>
#include
<random>
#include
<boost/test/included/unit_test.hpp>
...
...
@@ -20,25 +20,61 @@ namespace
{
float
x
=
0
,
y
=
0
,
z
=
0
;
};
}
}
// namespace
BOOST_AUTO_TEST_CASE
(
test_AABB_from_points_eigen
)
{
std
::
vector
<
Eigen
::
Vector3f
>
points
{
{
0
,
0
,
0
}
,
{
-
2
,
0
,
1
},
{
2
,
0
,
-
1
}
};
std
::
vector
<
Eigen
::
Vector3f
>
points
{
{
0
,
0
,
0
}
,
{
-
2
,
0
,
1
},
{
2
,
0
,
-
1
}
};
simox
::
AxisAlignedBoundingBox
aabb
=
simox
::
aabb
::
from_points
(
points
);
BOOST_CHECK_EQUAL
(
aabb
.
min
(),
Eigen
::
Vector3f
(
-
2
,
0
,
-
1
));
BOOST_CHECK_EQUAL
(
aabb
.
max
(),
Eigen
::
Vector3f
(
2
,
0
,
1
));
BOOST_CHECK_EQUAL
(
aabb
.
max
(),
Eigen
::
Vector3f
(
2
,
0
,
1
));
}
BOOST_AUTO_TEST_CASE
(
test_AABB_from_points_custom
)
{
std
::
vector
<
PointT
>
points
{
{
0
,
0
,
0
}
,
{
-
2
,
0
,
1
},
{
2
,
0
,
-
1
}
};
std
::
vector
<
PointT
>
points
{
{
0
,
0
,
0
}
,
{
-
2
,
0
,
1
},
{
2
,
0
,
-
1
}
};
simox
::
AxisAlignedBoundingBox
aabb
=
simox
::
aabb
::
from_points
(
points
);
BOOST_CHECK_EQUAL
(
aabb
.
min
(),
Eigen
::
Vector3f
(
-
2
,
0
,
-
1
));
BOOST_CHECK_EQUAL
(
aabb
.
max
(),
Eigen
::
Vector3f
(
2
,
0
,
1
));
BOOST_CHECK_EQUAL
(
aabb
.
max
(),
Eigen
::
Vector3f
(
2
,
0
,
1
));
}
BOOST_AUTO_TEST_CASE
(
test_overlaps
)
{
using
Eigen
::
Vector3f
;
using
AABB
=
simox
::
AxisAlignedBoundingBox
;
using
simox
::
aabb
::
is_colliding
;
const
AABB
lhs
(
Vector3f
(
-
1
,
-
2
,
-
3
),
Vector3f
(
1
,
2
,
3
));
// Collide with itself.
BOOST_CHECK
(
is_colliding
(
lhs
,
lhs
));
// Overlap when translated a bit.
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
0
,
-
2
,
-
3
),
Vector3f
(
2
,
2
,
3
))));
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
1
,
-
3
,
-
3
),
Vector3f
(
1
,
1
,
3
))));
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
1
,
-
2
,
2.5
),
Vector3f
(
1
,
2
,
6
))));
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
0
,
-
1
,
-
2
),
Vector3f
(
2
,
3
,
4
))));
// No overlap when translated to much.
BOOST_CHECK
(
not
is_colliding
(
lhs
,
AABB
(
Vector3f
(
2
,
-
2
,
-
3
),
Vector3f
(
4
,
2
,
3
))));
BOOST_CHECK
(
not
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
1
,
-
6
,
-
3
),
Vector3f
(
1
,
-
3
,
3
))));
BOOST_CHECK
(
not
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
1
,
-
2
,
4
),
Vector3f
(
1
,
2
,
10
))));
BOOST_CHECK
(
not
is_colliding
(
lhs
,
AABB
(
Vector3f
(
1.1
,
2.1
,
3.1
),
Vector3f
(
2
,
3
,
4
))));
BOOST_CHECK
(
not
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
2
,
-
3
,
-
4
),
Vector3f
(
-
1.1
,
-
2.1
,
-
3.1
))));
// rhs in lhs.
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
0.5
,
-
1.0
,
-
1.5
),
Vector3f
(
0.5
,
1.0
,
1.5
))));
// lhs in rhs.
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
2
,
-
4
,
-
6
),
Vector3f
(
2
,
4
,
6
))));
// More difficult cases.
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
-
0.5
,
-
10
,
-
20
),
Vector3f
(
0.5
,
10
,
20
))));
BOOST_CHECK
(
is_colliding
(
lhs
,
AABB
(
Vector3f
(
0.5
,
0.5
,
-
20
),
Vector3f
(
1.5
,
2.5
,
20
))));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment