sim.app.balls3d.Balls3D Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mason Show documentation
Show all versions of mason Show documentation
MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.
The newest version!
/*
Copyright 2006 by Sean Luke and George Mason University
Licensed under the Academic Free License version 3.0
See the file "LICENSE" for more information
*/
package sim.app.balls3d;
import sim.engine.*;
import sim.field.continuous.*;
import sim.field.network.*;
import sim.util.*;
public class Balls3D extends SimState
{
private static final long serialVersionUID = 1;
public Continuous3D balls;
public Network bands;
public int numBalls = 50;
public int numBands = 60;
public double gridWidth = 100;
public double gridHeight = 100;
public double gridLength = 100;
public final static double maxMass = 10.0;
public final static double minMass = 1.0;
public final static double minLaxBandDistance = 10.0;
public final static double maxLaxBandDistance = 50.0;
public final static double minBandStrength = 5.0;
public final static double maxBandStrength = 10.0;
public final static double collisionDistance = 5.0;
public int getNumBalls() { return numBalls; }
public void setNumBalls(int val) { if (val >= 2 ) numBalls = val; }
public int getNumBands() { return numBands; }
public void setNumBands(int val) { if (val >= 0 ) numBands = val; }
public Double3D[] getBallPositions()
{
if (balls == null) return new Double3D[0];
Bag bag = balls.getAllObjects();
if (bag == null) return new Double3D[0];
Double3D[] d = new Double3D[bag.size()];
for(int i = 0; i < d.length; i++)
{
d[i] = balls.getObjectLocation(bag.get(i));
}
return d;
}
public Balls3D(long seed)
{
super(seed);
}
public void start()
{
super.start();
balls = new Continuous3D(collisionDistance,gridWidth, gridHeight, gridLength);
bands = new Network();
Steppable[] s = new Steppable[numBalls];
// make the balls
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy