Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Feliks Kiszkurno
ogs-feliks
Commits
4e1e7ace
Commit
4e1e7ace
authored
10 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[GeoLib] Polygon::containsSegment(): Introduced tol variable.
Using the tol (tolerance) variable makes the code more readable.
parent
5078140c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/Polygon.cpp
+5
-3
5 additions, 3 deletions
GeoLib/Polygon.cpp
with
5 additions
and
3 deletions
GeoLib/Polygon.cpp
+
5
−
3
View file @
4e1e7ace
...
...
@@ -137,15 +137,17 @@ bool Polygon::containsSegment(GeoLib::Point const& a, GeoLib::Point const& b) co
return
(
isPntInPolygon
(
a
));
}
const
double
tol
(
std
::
numeric_limits
<
float
>::
epsilon
());
// one intersection, intersection in line segment end point
if
(
s
.
size
()
==
1
)
{
const
double
sqr_dist_as
(
MathLib
::
sqrDist
(
a
,
s
[
0
]));
if
(
sqr_dist_as
<
std
::
numeric_limits
<
float
>::
epsilon
()
)
{
if
(
sqr_dist_as
<
tol
)
{
return
(
isPntInPolygon
(
b
));
}
const
double
sqr_dist_bs
(
MathLib
::
sqrDist
(
b
,
s
[
0
]));
if
(
sqr_dist_bs
<
std
::
numeric_limits
<
float
>::
epsilon
()
)
{
if
(
sqr_dist_bs
<
tol
)
{
return
(
isPntInPolygon
(
a
));
}
}
...
...
@@ -160,7 +162,7 @@ bool Polygon::containsSegment(GeoLib::Point const& a, GeoLib::Point const& b) co
// remove sub segments with almost zero length
for
(
std
::
size_t
k
(
0
);
k
<
s
.
size
()
-
1
;
)
{
if
(
MathLib
::
sqrDist
(
s
[
k
],
s
[
k
+
1
])
<
std
::
numeric_limits
<
float
>::
epsilon
()
)
{
if
(
MathLib
::
sqrDist
(
s
[
k
],
s
[
k
+
1
])
<
tol
)
{
s
.
erase
(
s
.
begin
()
+
k
+
1
);
}
else
{
k
++
;
...
...
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