Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
43e052d4
Commit
43e052d4
authored
Jan 15, 2019
by
Benedikt Zoennchen
Browse files
issue#198: wrong distance computation for VPolygon.
parent
116fec10
Changes
1
Hide whitespace changes
Inline
Side-by-side
VadereUtils/src/org/vadere/util/geometry/shapes/VPolygon.java
View file @
43e052d4
...
...
@@ -406,6 +406,7 @@ public class VPolygon extends Path2D.Double implements VShape {
PathIterator
iterator
=
this
.
getPathIterator
(
null
);
double
[]
first
=
null
;
double
[]
last
=
new
double
[
2
];
double
[]
next
=
new
double
[
2
];
VPoint
currentClosest
;
...
...
@@ -417,6 +418,10 @@ public class VPolygon extends Path2D.Double implements VShape {
last
[
0
]
=
next
[
0
];
last
[
1
]
=
next
[
1
];
if
(
first
==
null
)
{
first
=
new
double
[]{
last
[
0
],
last
[
1
]};
}
iterator
.
currentSegment
(
next
);
currentClosest
=
GeometryUtils
.
closestToSegment
(
new
VLine
(
last
[
0
],
...
...
@@ -430,6 +435,17 @@ public class VPolygon extends Path2D.Double implements VShape {
iterator
.
next
();
}
// dont forget the last and first point!
if
(
first
!=
null
)
{
currentClosest
=
GeometryUtils
.
closestToSegment
(
new
VLine
(
next
[
0
],
next
[
1
],
first
[
0
],
first
[
1
]),
point
);
if
(
currentClosest
.
distance
(
point
)
<
currentMinDistance
)
{
currentMinDistance
=
currentClosest
.
distance
(
point
);
resultPoint
=
currentClosest
;
}
}
return
resultPoint
;
}
...
...
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