Package worldBuilder
Class Cartesian
- java.lang.Object
-
- worldBuilder.Cartesian
-
public class Cartesian extends java.lang.Object
a dense 2D array w/Cartesian coordinates, whose values have been interpolated from the Voronoi mesh points.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Cartesian.vicinity
types of vicinities
-
Constructor Summary
Constructors Constructor Description Cartesian(Mesh mesh, double left, double top, double right, double bottom, int width, int height, Cartesian.vicinity type)
create a new Cartesian map
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int[][]
encode(double[][] array, int minValue, int maxValue)
interpret a 2D array of doubles into ranges in an integer value (typically used to translate altitudes to colorsdouble[][]
interpolate(double[] meshValues)
interpolate values for every Cartesian celldouble[][]
nearest(double[] meshValues)
use nearest MeshPoint value for every Cartesian cellstatic void
smooth(double[][] array)
perform Gaussian Blurr on a (potentially noisy) array
-
-
-
Field Detail
-
width
public int width
number of tile columns in this map
-
height
public int height
number of tile rows in this map
-
cells
public Vicinity[][] cells
the nearest MeshPoints to every tile in our map
-
-
Constructor Detail
-
Cartesian
public Cartesian(Mesh mesh, double left, double top, double right, double bottom, int width, int height, Cartesian.vicinity type)
create a new Cartesian map- Parameters:
mesh
- ... Mesh of Voronoi pointsleft
- ... left edge of mapped areatop
- ... top of mapped arearight
- ... right edge of mapped areabottom
- ... bottom edge of mapped areawidth
- ... width of desired arrayheight
- ... height of desired arraytype
- ... type of vicinity (NEAREST, NEIGHBORS, POLYGON)
-
-
Method Detail
-
interpolate
public double[][] interpolate(double[] meshValues)
interpolate values for every Cartesian cell- Parameters:
meshValues
- - array of per-MeshPoint values- Returns:
- Cartesian array of interpolated values
-
nearest
public double[][] nearest(double[] meshValues)
use nearest MeshPoint value for every Cartesian cell- Parameters:
meshValues
- - array of per-MeshPoint values- Returns:
- Cartesian array of per-tile values
-
encode
public static int[][] encode(double[][] array, int minValue, int maxValue)
interpret a 2D array of doubles into ranges in an integer value (typically used to translate altitudes to colors- Parameters:
array
- - 2D array of doublesminValue
- - minimum value of output rangemaxValue
- - maximum value of output range- Returns:
- 2D array of integers representing re-encoded values
-
smooth
public static void smooth(double[][] array)
perform Gaussian Blurr on a (potentially noisy) array- Parameters:
array
- - 2D array of doubles The Cartesian translation process can yield discontinuities when neighboring tiles have different sets of closest MeshPoints. In most cases, these are inconsequential, but they need to be cleaned up for high-resolution altitude maps. A 2D Gaussian Kernel is merely the product of a pair of 1D kernels, but (because multiplication is associative) we can get the same result in (O(n) time) by applying the 1D kernel twice: 1. recompute each point as the average of its horizontal neighbors 2. recompute each point as the average of its vertical neighbors
-
-