Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
b0947a8e
Commit
b0947a8e
authored
Mar 11, 2019
by
Julian Zobel
Browse files
Bugfix, now random locations are completely within the world dimensions
parent
049e341a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/RandomAttractionGenerator.java
View file @
b0947a8e
...
...
@@ -103,13 +103,19 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
if
(
c
<
20
)
{
// if not within the world dimensions, directly go back to calculation
if
(
posVec
.
getX
()
+
radius
>
worldDimension
.
getX
()
||
posVec
.
getY
()
+
radius
>
worldDimension
.
getY
()
||
posVec
.
getX
()
-
radius
<
0
||
posVec
.
getY
()
-
radius
<
0
)
{
i
--;
c
++;
continue
create
;
}
for
(
AttractionPoint
ap
:
result
)
{
// if this point is closer than the given minimum distance to another point, or the radii of the points would overlap,
// or if the radius would exceed the simulation area
// then discard this attraction point and create a new one
if
(
posVec
.
distanceTo
(
ap
)
<
minimumDistance
||
(
posVec
.
distanceTo
(
ap
)
-
radius
-
ap
.
getRadius
())
<
0
||
posVec
.
getX
()
+
radius
>
worldDimension
.
getX
()
||
posVec
.
getY
()
+
radius
>
worldDimension
.
getY
()
||
posVec
.
getX
()
-
radius
<
0
||
posVec
.
getY
()
-
radius
<
0
)
{
if
(
posVec
.
distanceTo
(
ap
)
<
minimumDistance
||
(
posVec
.
distanceTo
(
ap
)
-
radius
-
ap
.
getRadius
())
<
0
)
{
i
--;
c
++;
continue
create
;
...
...
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