Purpose: A utility class that can be used to perform operations on N-dimenionsal lines, triangles, and polygons.
About the System: This class will be used by a 2D renderer and a 3D renderer (and, perhaps, other classes).
Details
The barycentricCombination() Method:
/** * Returns the point alpha q + (1-alpha)r * * @param q One point * @param r The other points * @param alpha The weight */ public static double[] barycentricCombination(double[] q, double[] r, double alpha)
The boundingRectangle() Method:
/** * Returns the bounding rectangle (i.e., the smallest rectangle * that completely contains the given line, triangle, or polygon * * Note: This method should return an array of two points (i.e., * an array of arrays). The first point should contain the * minimum x and y (i.e., the lower-left corner), and the second * point should contain the maximum x and y (i.e., the * upper-right corner). * * @param p The line, triangle, or polygon * @return The bounding rectangle (as described above) */ public static double[][] boundingRectangle(double[]... p)
Note that this method uses a variable length parameter list. You
may, if you prefer, use double[][] p
instead. The
advantage of the vaiable length paramter list is that the
method can be passed either a two-dimensional array or multiple
one dimensional arrays. For example, all of the following
would be valid:
double[][] p, rect; double[] r, s, t; // Initialization rect = GeometryND.boundingRectangle(p); rect = GeometryND.boundingRectangle(r, s); rect = GeometryND.boundingRectangle(r, s, t);
Copyright 2007