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
914db13b
Commit
914db13b
authored
Dec 06, 2018
by
Julian Zobel
Browse files
Added a minimum distance between APs in the random AP generator
parent
2fdea5df
Changes
2
Hide whitespace changes
Inline
Side-by-side
.settings/org.eclipse.jdt.core.prefs
View file @
914db13b
...
...
@@ -98,6 +98,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,NORMAL,LOW
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/RandomAttractionGenerator.java
View file @
914db13b
...
...
@@ -37,9 +37,12 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
*
* Generates the given number of {@link AttractionPoint}s and sets the
* position randomly within the world dimensions.
*
* v1.1: statically available attraction points [JZ]
* v1.2: added a minimum distance between attraction points [JZ]
*
* @author Christoph Muenker, Julian Zobel
* @version 1.
1
,
09
2018
* @version 1.
2
,
11
2018
*/
public
class
RandomAttractionGenerator
implements
IAttractionGenerator
{
...
...
@@ -51,6 +54,8 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
private
boolean
numberOfAPsSet
=
false
;
private
double
minimumDistance
=
50
;
@XMLConfigurableConstructor
({
"numberOfAttractionPoints"
})
public
RandomAttractionGenerator
(
int
numberOfAttractionPoints
)
{
this
.
rand
=
Randoms
.
getRandom
(
RandomAttractionGenerator
.
class
);
...
...
@@ -81,8 +86,17 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
private
void
createAttractionPoints
()
{
List
<
AttractionPoint
>
result
=
new
LinkedList
<
AttractionPoint
>();
for
(
int
i
=
0
;
i
<
numberOfAttractionPoints
;
i
++)
{
create:
for
(
int
i
=
0
;
i
<
numberOfAttractionPoints
;
i
++)
{
PositionVector
posVec
=
createPosVec
();
for
(
AttractionPoint
ap
:
result
)
{
if
(
posVec
.
distanceTo
(
ap
)
<
minimumDistance
)
{
i
--;
continue
create
;
}
}
AttractionPoint
aPoint
=
new
AttractionPointImpl
(
"AP"
+
i
,
posVec
);
result
.
add
(
aPoint
);
}
...
...
@@ -96,5 +110,12 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
double
y
=
rand
.
nextDouble
()
*
worldDimension
.
getY
();
return
new
PositionVector
(
x
,
y
);
}
/**
* Set a minimum distance between the randomly generated attraction points
* @param distance
*/
public
void
setMinimumDistance
(
double
distance
)
{
this
.
minimumDistance
=
distance
;
}
}
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