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
c13848e9
Commit
c13848e9
authored
6 years ago
by
Stefan Reither
Browse files
Options
Downloads
Patches
Plain Diff
add method for checking if 3DPoint is inside of bounding box
parent
b65af5f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
VirtualRobot/BoundingBox.cpp
+31
-0
31 additions, 0 deletions
VirtualRobot/BoundingBox.cpp
VirtualRobot/BoundingBox.h
+9
-0
9 additions, 0 deletions
VirtualRobot/BoundingBox.h
with
40 additions
and
0 deletions
VirtualRobot/BoundingBox.cpp
+
31
−
0
View file @
c13848e9
...
...
@@ -216,4 +216,35 @@ namespace VirtualRobot
return
ss
.
str
();
}
bool
BoundingBox
::
isInside
(
Eigen
::
Vector3f
point
)
const
{
Eigen
::
Vector3f
p0
(
min
(
0
),
min
(
1
),
min
(
2
));
Eigen
::
Vector3f
p1
(
min
(
0
),
min
(
1
),
max
(
2
));
Eigen
::
Vector3f
p2
(
min
(
0
),
max
(
1
),
min
(
2
));
Eigen
::
Vector3f
p4
(
max
(
0
),
min
(
1
),
min
(
2
));
Eigen
::
Vector3f
v01
=
p0
-
p1
;
Eigen
::
Vector3f
v02
=
p0
-
p2
;
Eigen
::
Vector3f
v04
=
p0
-
p4
;
point
(
0
)
=
std
::
isnan
(
point
(
0
))
?
(
max
(
0
)
+
min
(
0
))
/
2
:
point
(
0
);
point
(
1
)
=
std
::
isnan
(
point
(
1
))
?
(
max
(
1
)
+
min
(
1
))
/
2
:
point
(
1
);
point
(
2
)
=
std
::
isnan
(
point
(
2
))
?
(
max
(
2
)
+
min
(
2
))
/
2
:
point
(
2
);
auto
isBetween
=
[](
float
x
,
float
a
,
float
b
)
{
if
(
a
<=
b
)
{
return
a
<=
x
&&
x
<=
b
;
}
else
{
return
b
<=
x
&&
x
<=
a
;
}
};
return
isBetween
(
v01
.
dot
(
point
),
v01
.
dot
(
p0
),
v01
.
dot
(
p1
))
&&
isBetween
(
v02
.
dot
(
point
),
v02
.
dot
(
p0
),
v02
.
dot
(
p2
))
&&
isBetween
(
v04
.
dot
(
point
),
v04
.
dot
(
p0
),
v04
.
dot
(
p4
));
}
}
This diff is collapsed.
Click to expand it.
VirtualRobot/BoundingBox.h
+
9
−
0
View file @
c13848e9
...
...
@@ -92,6 +92,15 @@ namespace VirtualRobot
std
::
string
toXML
(
int
tabs
=
2
,
bool
skipMatrixTag
=
false
);
/*!
* \brief isInside Checks whether the given point lies within the bounding box. The given vector can contain
* entries that are none, if this is the case the respective dimension is ignored and the point is only tested
* for the remaining non-nan dimensions.
* \param point the point to test
* \return True if the point lies within the bounding box. False if not.
*/
bool
isInside
(
Eigen
::
Vector3f
point
)
const
;
protected:
Eigen
::
Vector3f
min
;
Eigen
::
Vector3f
max
;
...
...
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