Geometry
Class Topology

java.lang.Object
  |
  +--Geometry.Topology

public class Topology
extends java.lang.Object

Builds the positions that can be randomly selected within the region it is associated with. The random distribution is based on the shape of the region; currently only wedges and toroids are supported. A bell curve with adjustable decay rate is applied to make positions nearer the center more probable than those at the edges.

Version:
Created 12 August 2003
Author:
Dan Tappan
See Also:
Region

Field Summary
private static float CELL_BASE
           
static float DEFAULT_DECAY_RATE
           
private  int GENERATION_BASE
           
private  java.util.ArrayList m_cell_list
           
private  float[][] m_generation_count
           
private  float m_max_generation_count
           
private  Region m_region
           
static int NUM_CELL_SUBDIVISIONS
           
static int NUM_RINGS
           
static int NUM_SECTORS
           
 
Constructor Summary
protected Topology(Region parent_region, float decay_rate)
          Creates a new topology for distributing random coordinates over a region.
protected Topology(Region parent_region, Topology topology1, Topology topology2)
          Creates a new topology for distributing random coordinates over a region.
 
Method Summary
private  void createDistribution(float decay_rate)
          Creates a distribution of random coordinates over a region based on its shape.
private  void createToroidDistribution(int sector_start, int sector_end, int sector_center, int ring_start, int ring_end, int ring_center, float decay_rate)
          Creates a random distribution over a toroid-shaped region.
private  void createWedgeDistribution(int sector_start, int sector_end, int sector_center, int ring_start, int ring_end, int ring_center, float decay_rate)
          Creates a random distribution over a wedge-shaped region.
 void dumpActualDistribution(int sample_size)
          Dumps to stdout a list of actual random coordinates over a sample to show how an actual distribution corresponds to the predicted one.
 void dumpPredictedDistribution(boolean is_histogram_otherwise_gnuplot)
          Dumps to stdout a list of predicted random coordinates to show how an actual distribution should look.
private  void generateRandomList()
          Generates a list of random coordinates based on the distribution.
 java.util.ArrayList getCellMesh(int geometry_ring, int geometry_sector)
          Returns a list RegionCoordinates corresponding to the corners of all topology cells within a region cell.
protected  float getGenerationCount(int ring, int sector)
          Returns the number of random coordinates to generate for a topology cell.
static int getNextSector(int sector)
          Returns the next topology sector number.
static int getPreviousSector(int sector)
          Returns the previous topology sector number.
 RegionCoordinate getRandomCoordinate()
          Returns a random coordinate distributed over the topology.
 int getRandomPoolSize()
          Returns the number of random coordinates available.
static float getRegionRing(int topology_ring)
          Returns the Region ring (or fraction thereof) corresponding to a Topology ring.
static float getRegionSector(int topology_sector)
          Returns the Region sector (or fraction thereof) corresponding to a Topology sector.
static int getTopologyRingLowerBound(int region_ring)
          Returns the smallest Topology ring corresponding to a Region ring.
static int getTopologyRingUpperBound(int region_ring)
          Returns the largest Topology ring corresponding to a Region ring.
static int getTopologySectorLowerBound(int region_sector)
          Returns the smallest Topology sector corresponding to a Region sector.
static int getTopologySectorUpperBound(int region_sector)
          Returns the largest Topology sector corresponding to a Region sector.
private  void initialize()
          Initializes the topology.
private  void joinDistributions(Topology topology1, Topology topology2)
          Builds a new topology as the sum of two existing topologies.
 java.lang.String toString()
          Returns a string representation of this object.
 java.lang.String toString(boolean list_cells)
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_CELL_SUBDIVISIONS

public static final int NUM_CELL_SUBDIVISIONS
See Also:
Constant Field Values

CELL_BASE

private static final float CELL_BASE
See Also:
Constant Field Values

GENERATION_BASE

private int GENERATION_BASE

NUM_RINGS

public static final int NUM_RINGS
See Also:
Constant Field Values

NUM_SECTORS

public static final int NUM_SECTORS
See Also:
Constant Field Values

DEFAULT_DECAY_RATE

public static final float DEFAULT_DECAY_RATE
See Also:
Constant Field Values

m_generation_count

private float[][] m_generation_count

m_max_generation_count

private float m_max_generation_count

m_cell_list

private java.util.ArrayList m_cell_list

m_region

private Region m_region
Constructor Detail

Topology

protected Topology(Region parent_region,
                   float decay_rate)
Creates a new topology for distributing random coordinates over a region. The central tendency of the distribution is evenly down the center of a wedge or evenly riding around the high point of a ring. The measure of variability is normally defined as a bell curve (without standard-deviation constraints), but other distributions are possible.

Parameters:
parent_region - - the region this topology is associated with
decay_rate - - the decay rate of the distribution curve: 0=uniform, 1=concave, 2+=bell (larger produces a wider bell), negative=bimodal

Topology

protected Topology(Region parent_region,
                   Topology topology1,
                   Topology topology2)
Creates a new topology for distributing random coordinates over a region. This constructor is called only to build the topology for the result of the logical join of two regions.

Parameters:
parent_region - - the region this topology is associated with
topology1 - - the topology of the first region contributing to the join
topology2 - - the topology of the second region contributing to the join
Method Detail

createDistribution

private void createDistribution(float decay_rate)
Creates a distribution of random coordinates over a region based on its shape. Only wedges and toroids are currently supported.

Parameters:
decay_rate - - the decay rate of the distribution curve, as defined in the constructor
See Also:
Topology(Geometry.Region, Geometry.Topology, Geometry.Topology)

createToroidDistribution

private void createToroidDistribution(int sector_start,
                                      int sector_end,
                                      int sector_center,
                                      int ring_start,
                                      int ring_end,
                                      int ring_center,
                                      float decay_rate)
Creates a random distribution over a toroid-shaped region. The most likely coordinates appear through the center of the ring and taper outward to the least likely.

The distribution is based on the following equation (formatted for GnuPlot):

   plot [0:1] 100**-x**decay_rate * GENERATION_BASE + 1
 

Parameters:
sector_start - - the start sector
sector_end - - the end sector
sector_center - - the best-fitting center sector
ring_start - - the start ring
ring_end - - the end ring
ring_center - - the best-fitting center ring
decay_rate - - the decay rate of the distribution curve, as defined in the constructor
See Also:
Topology(Geometry.Region, Geometry.Topology, Geometry.Topology)

createWedgeDistribution

private void createWedgeDistribution(int sector_start,
                                     int sector_end,
                                     int sector_center,
                                     int ring_start,
                                     int ring_end,
                                     int ring_center,
                                     float decay_rate)
Creates a random distribution over a wedge-shaped region. The most likely coordinates appear down the center of the wedge and taper outward to the least likely.

The distribution is based on the following equation (formatted for GnuPlot):

   plot [0:1] 100**-x**decay_rate * GENERATION_BASE + 1
 

Parameters:
sector_start - - the start sector
sector_end - - the end sector
sector_center - - the best-fitting center sector
ring_start - - the start ring
ring_end - - the end ring
ring_center - - the best-fitting center ring
decay_rate - - the decay rate of the distribution curve, as defined in the constructor
See Also:
Topology(Geometry.Region, Geometry.Topology, Geometry.Topology)

dumpActualDistribution

public void dumpActualDistribution(int sample_size)
Dumps to stdout a list of actual random coordinates over a sample to show how an actual distribution corresponds to the predicted one.

This is for development use only.

Parameters:
sample_size - - the sample size

dumpPredictedDistribution

public void dumpPredictedDistribution(boolean is_histogram_otherwise_gnuplot)
Dumps to stdout a list of predicted random coordinates to show how an actual distribution should look.

This is for development use only.


getGenerationCount

protected float getGenerationCount(int ring,
                                   int sector)
Returns the number of random coordinates to generate for a topology cell.

Parameters:
ring - - the ring
sector - - the sector
Returns:
the number of coordinates. This is a float because it also serves as the elevation for generating a cell mesh

getNextSector

public static int getNextSector(int sector)
Returns the next topology sector number. This adds 1 to the current sector except when the last sector needs to wrap around to the first.

Parameters:
sector - - the sector
Returns:
the next sector number

getPreviousSector

public static int getPreviousSector(int sector)
Returns the previous topology sector number. This substract 1 to the current sector except when the first sector needs to wrap around to the last.

Parameters:
sector - - the sector
Returns:
the previous sector number

generateRandomList

private void generateRandomList()
Generates a list of random coordinates based on the distribution.


getCellMesh

public java.util.ArrayList getCellMesh(int geometry_ring,
                                       int geometry_sector)
Returns a list RegionCoordinates corresponding to the corners of all topology cells within a region cell.

Parameters:
geometry_ring - - the region ring
geometry_sector - - the region sector
Returns:
the list, which can feed into a Java3D QuadArray after coordinate manipulation
See Also:
RegionCoordinate

getRandomCoordinate

public RegionCoordinate getRandomCoordinate()
Returns a random coordinate distributed over the topology.

Returns:
the coordinate

getRandomPoolSize

public int getRandomPoolSize()
Returns the number of random coordinates available. If this is considered too small, increase GENERATION_BASE.

Returns:
the size

getRegionRing

public static float getRegionRing(int topology_ring)
Returns the Region ring (or fraction thereof) corresponding to a Topology ring. Since multiple topology cells exists within a single geometry cell, a fractional value is possible.

Parameters:
topology_ring - - the topology ring
Returns:
the region ring

getRegionSector

public static float getRegionSector(int topology_sector)
Returns the Region sector (or fraction thereof) corresponding to a Topology sector. Since multiple topology cells exists within a single geometry cell, a fractional value is possible.

Parameters:
topology_sector - - the topology sector
Returns:
the region sector

getTopologyRingLowerBound

public static int getTopologyRingLowerBound(int region_ring)
Returns the smallest Topology ring corresponding to a Region ring. Since multiple topology cells exists within a single geometry cell, there is no one-to-one correspondence in this conversion direction.

Parameters:
region_ring - - the region ring
Returns:
the lower-bounded topology ring

getTopologyRingUpperBound

public static int getTopologyRingUpperBound(int region_ring)
Returns the largest Topology ring corresponding to a Region ring. Since multiple topology cells exists within a single geometry cell, there is no one-to-one correspondence in this conversion direction.

Parameters:
region_ring - - the region ring
Returns:
the upper-bounded topology ring

getTopologySectorLowerBound

public static int getTopologySectorLowerBound(int region_sector)
Returns the smallest Topology sector corresponding to a Region sector. Since multiple topology cells exists within a single geometry cell, there is no one-to-one correspondence in this conversion direction.

Returns:
the lower-bounded topology ring

getTopologySectorUpperBound

public static int getTopologySectorUpperBound(int region_sector)
Returns the largest Topology sector corresponding to a Region sector. Since multiple topology cells exists within a single geometry cell, there is no one-to-one correspondence in this conversion direction.

Returns:
the upper-bounded topology ring

initialize

private void initialize()
Initializes the topology.


joinDistributions

private void joinDistributions(Topology topology1,
                               Topology topology2)
Builds a new topology as the sum of two existing topologies. This is used after logically joining two regions.

Parameters:
topology1 - - the topology of the first region contributing to the join
topology2 - - the topology of the second region contributing to the join

toString

public java.lang.String toString()
Returns a string representation of this object. Individual cells are not listed; to do so, use the other variant of this method.

Overrides:
toString in class java.lang.Object
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String), toString(boolean)

toString

public java.lang.String toString(boolean list_cells)
Returns a string representation of this object.

Parameters:
list_cells - - whether the contents of each cell should be listed
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)