public class ZOI extends Object
Constructor and Description |
---|
ZOI(Coord[][] influences,
char[][] map,
Radius measurement)
Constructs a Zone of Influence map.
|
ZOI(Coord[] influences,
char[][] map,
Radius measurement)
Constructs a Zone of Influence map.
|
Modifier and Type | Method and Description |
---|---|
short[][] |
calculate()
Finds the zones of influence for each of the influences (inner arrays of Coord) this was constructed with, and
returns them as packed data (using CoordPacker, which can also be used to unpack the data, merge zones, get
shared borders, and all sorts of other tricks).
|
Coord[][] |
getInfluences()
Gets the influencing groups; ideally the result should not be changed without setting it back with setInfluences.
|
protected boolean[][] |
increasing(double[][] dm,
Coord[] inf) |
int[] |
nearestInfluences(Coord point)
This can be given a Coord to check in the results of the latest calculate() call.
|
int[] |
nearestInfluences(short[][] zones,
Coord point)
Given the zones resulting from this class' calculate method and a Coord to check, finds the indices of all
influencing groups in zones that have the Coord in their area, and returns all such indices as an int array.
|
void |
setInfluences(Coord[][] influences)
Changes the influencing groups.
|
public ZOI(Coord[][] influences, char[][] map, Radius measurement)
influences
- an outer array containing influencing groups, each an array containing Coords that influencemap
- a char[][] that is used as a map; should be boundedmeasurement
- a Radius enum that corresponds to how distance should be measuredpublic ZOI(Coord[] influences, char[][] map, Radius measurement)
influences
- an array containing Coords that each have their own independent influencemap
- a char[][] that is used as a map; should be boundedmeasurement
- a Radius enum that corresponds to how distance should be measuredfor a good way to generate evenly spaced Coords that can be used here
public short[][] calculate()
short[] different = CoordPacker.differencePacked(A, B)
. Merging two zones A and B
can be done with short[] merged = CoordPacker.unionPacked(A, B)
. You can unpack the data
into a boolean[][] easily with CoordPacker.unpack(), where true is contained in the zone and false is not.
The CoordPacker methods fringe(), expand(), singleRandom(), randomSample(), and randomPortion() are also
potentially useful for this sort of data. You should save the short[][] for later use if you want to call
nearestInfluences() in this class.
protected boolean[][] increasing(double[][] dm, Coord[] inf)
public int[] nearestInfluences(short[][] zones, Coord point)
zones
- a short[][] returned by calculate; not a multi-packed short[][] from CoordPacker !point
- the Coord to testpublic int[] nearestInfluences(Coord point)
point
- the Coord to testpublic Coord[][] getInfluences()
public void setInfluences(Coord[][] influences)
influences
- a jagged array of Coord arrays, where the inner arrays are groups of influencesCopyright © 2012–2016. All rights reserved.