Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
coal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coal
coal
Commits
4c14cc3e
Commit
4c14cc3e
authored
6 years ago
by
Florent Lamiraux
Committed by
Florent Lamiraux florent@laas.fr
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Simplify collision test between OBB.
parent
cb68e2b8
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
src/BV/OBB.cpp
+28
-68
28 additions, 68 deletions
src/BV/OBB.cpp
with
28 additions
and
68 deletions
src/BV/OBB.cpp
+
28
−
68
View file @
4c14cc3e
...
...
@@ -33,11 +33,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Jia Pan */
/** \author Jia Pan
, Florent Lamiraux
*/
#include
<hpp/fcl/BV/OBB.h>
#include
<hpp/fcl/BVH/BVH_utility.h>
#include
<hpp/fcl/math/transform.h>
#include
<hpp/fcl/collision_data.h>
#include
<iostream>
#include
<limits>
...
...
@@ -294,85 +295,44 @@ bool obbDisjoint(const Matrix3f& B, const Vec3f& T, const Vec3f& a, const Vec3f&
// B, T orientation and position of 2nd OBB in frame of 1st OBB,
// a extent of 1st OBB,
// b extent of 2nd OBB.
//
// This function tests whether bounding boxes should be broken down.
//
bool
obbDisjointAndLowerBoundDistance
(
const
Matrix3f
&
B
,
const
Vec3f
&
T
,
const
Vec3f
&
a
,
const
Vec3f
&
b
,
const
CollisionRequest
&
request
,
FCL_REAL
&
squaredLowerBoundDistance
)
{
FCL_REAL
t
,
s
;
const
FCL_REAL
reps
=
1e-6
;
FCL_REAL
diff
;
FCL_REAL
breakDistance
=
2e-3
*
(
a
[
0
]
+
a
[
1
]
+
a
[
2
]
+
b
[
0
]
+
b
[
1
]
+
b
[
2
]);
FCL_REAL
breakDistance
(
request
.
break_distance
+
request
.
security_margin
);
FCL_REAL
breakDistance2
=
breakDistance
*
breakDistance
;
// Matrix3f Bf = abs(B);
// Bf += reps;
Matrix3f
Bf
(
B
.
array
().
abs
()
+
reps
);
squaredLowerBoundDistance
=
0
;
// if any of these tests are one-sided, then the polyhedra are disjoint
// A1 x A2 = A0
t
=
((
T
[
0
]
<
0.0
)
?
-
T
[
0
]
:
T
[
0
]);
diff
=
t
-
(
a
[
0
]
+
Bf
.
row
(
0
).
dot
(
b
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
// A2 x A0 = A1
t
=
((
T
[
1
]
<
0.0
)
?
-
T
[
1
]
:
T
[
1
]);
diff
=
t
-
(
a
[
1
]
+
Bf
.
row
(
1
).
dot
(
b
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
// A0 x A1 = A2
t
=
((
T
[
2
]
<
0.0
)
?
-
T
[
2
]
:
T
[
2
]);
diff
=
t
-
(
a
[
2
]
+
Bf
.
row
(
2
).
dot
(
b
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
Matrix3f
Bf
(
B
.
cwiseAbs
());
// Corner of b axis aligned bounding box the closest to the origin
Vec3f
AABB_corner
(
T
.
cwiseAbs
()
-
Bf
*
b
);
Vec3f
diff3
(
AABB_corner
-
a
);
diff3
=
diff3
.
cwiseMax
(
0
);
//for (Vec3f::Index i=0; i<3; ++i) diff3 [i] = std::max (0, diff3 [i]);
squaredLowerBoundDistance
=
diff3
.
squaredNorm
();
if
(
squaredLowerBoundDistance
>
breakDistance2
)
return
true
;
// B1 x B2 = B0
s
=
B
.
col
(
0
).
dot
(
T
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
diff
=
t
-
(
b
[
0
]
+
Bf
.
col
(
0
).
dot
(
a
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
// B2 x B0 = B1
s
=
B
.
col
(
1
).
dot
(
T
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
diff
=
t
-
(
b
[
1
]
+
Bf
.
col
(
1
).
dot
(
a
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
// B0 x B1 = B2
s
=
B
.
col
(
2
).
dot
(
T
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
diff
=
t
-
(
b
[
2
]
+
Bf
.
col
(
2
).
dot
(
a
));
if
(
diff
>
0
)
{
squaredLowerBoundDistance
+=
diff
*
diff
;
}
AABB_corner
=
(
B
.
transpose
()
*
T
).
cwiseAbs
()
-
Bf
.
transpose
()
*
a
;
// diff3 = | B^T T| - b - Bf^T a
diff3
=
AABB_corner
-
b
;
diff3
=
diff3
.
cwiseMax
(
0
);
squaredLowerBoundDistance
=
diff3
.
squaredNorm
();
if
(
squaredLowerBoundDistance
>
breakDistance2
)
return
true
;
// A0 x B0
s
=
T
[
2
]
*
B
(
1
,
0
)
-
T
[
1
]
*
B
(
2
,
0
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
FCL_REAL
sinus2
;
diff
=
t
-
(
a
[
1
]
*
Bf
(
2
,
0
)
+
a
[
2
]
*
Bf
(
1
,
0
)
+
...
...
@@ -393,7 +353,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A0 x B1
s
=
T
[
2
]
*
B
(
1
,
1
)
-
T
[
1
]
*
B
(
2
,
1
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
1
]
*
Bf
(
2
,
1
)
+
a
[
2
]
*
Bf
(
1
,
1
)
+
b
[
0
]
*
Bf
(
0
,
2
)
+
b
[
2
]
*
Bf
(
0
,
0
));
...
...
@@ -409,7 +369,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A0 x B2
s
=
T
[
2
]
*
B
(
1
,
2
)
-
T
[
1
]
*
B
(
2
,
2
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
1
]
*
Bf
(
2
,
2
)
+
a
[
2
]
*
Bf
(
1
,
2
)
+
b
[
0
]
*
Bf
(
0
,
1
)
+
b
[
1
]
*
Bf
(
0
,
0
));
...
...
@@ -425,7 +385,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A1 x B0
s
=
T
[
0
]
*
B
(
2
,
0
)
-
T
[
2
]
*
B
(
0
,
0
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
2
,
0
)
+
a
[
2
]
*
Bf
(
0
,
0
)
+
b
[
1
]
*
Bf
(
1
,
2
)
+
b
[
2
]
*
Bf
(
1
,
1
));
...
...
@@ -441,7 +401,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A1 x B1
s
=
T
[
0
]
*
B
(
2
,
1
)
-
T
[
2
]
*
B
(
0
,
1
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
2
,
1
)
+
a
[
2
]
*
Bf
(
0
,
1
)
+
b
[
0
]
*
Bf
(
1
,
2
)
+
b
[
2
]
*
Bf
(
1
,
0
));
...
...
@@ -457,7 +417,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A1 x B2
s
=
T
[
0
]
*
B
(
2
,
2
)
-
T
[
2
]
*
B
(
0
,
2
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
2
,
2
)
+
a
[
2
]
*
Bf
(
0
,
2
)
+
b
[
0
]
*
Bf
(
1
,
1
)
+
b
[
1
]
*
Bf
(
1
,
0
));
...
...
@@ -473,7 +433,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A2 x B0
s
=
T
[
1
]
*
B
(
0
,
0
)
-
T
[
0
]
*
B
(
1
,
0
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
1
,
0
)
+
a
[
1
]
*
Bf
(
0
,
0
)
+
b
[
1
]
*
Bf
(
2
,
2
)
+
b
[
2
]
*
Bf
(
2
,
1
));
...
...
@@ -489,7 +449,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A2 x B1
s
=
T
[
1
]
*
B
(
0
,
1
)
-
T
[
0
]
*
B
(
1
,
1
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
1
,
1
)
+
a
[
1
]
*
Bf
(
0
,
1
)
+
b
[
0
]
*
Bf
(
2
,
2
)
+
b
[
2
]
*
Bf
(
2
,
0
));
...
...
@@ -505,7 +465,7 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
// A2 x B2
s
=
T
[
1
]
*
B
(
0
,
2
)
-
T
[
0
]
*
B
(
1
,
2
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
t
=
((
s
<
0.0
)
?
-
s
:
s
);
assert
(
t
==
fabs
(
s
));
diff
=
t
-
(
a
[
0
]
*
Bf
(
1
,
2
)
+
a
[
1
]
*
Bf
(
0
,
2
)
+
b
[
0
]
*
Bf
(
2
,
1
)
+
b
[
1
]
*
Bf
(
2
,
0
));
...
...
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