Package edu.cnu.mdi.geometry
Class GeoUtil
java.lang.Object
edu.cnu.mdi.geometry.GeoUtil
Shared numerical constants and array utilities for the geometry package.
This class centralizes the small tolerance used throughout the package for
"effectively zero" comparisons, so that Vector, Line,
Plane, and others share a single definition rather than each declaring
their own copy. It also hosts the general-purpose array arithmetic that is not
specific to three-dimensional geometry.
The class is non-instantiable and contains only static members.
- Author:
- heddle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleEffectively zero for parallelism, degeneracy, and normalization tests. -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]addVectors(double[]... vectors) Adds one or more array-based vectors element by element.static double[]scalarMultiply(double[] vector, double scalar) Multiplies every element of an arbitrary numeric vector by a scalar.static booleantiny(double v) Tests whether a value is effectively zero.
-
Field Details
-
TINY
public static final double TINYEffectively zero for parallelism, degeneracy, and normalization tests.- See Also:
-
-
Method Details
-
tiny
public static boolean tiny(double v) Tests whether a value is effectively zero.- Parameters:
v- the value to test- Returns:
trueifabs(v) < TINY
-
scalarMultiply
public static double[] scalarMultiply(double[] vector, double scalar) Multiplies every element of an arbitrary numeric vector by a scalar.This utility is for array-based vector data, not necessarily for 3D geometry vectors.
- Parameters:
vector- the array to multiplyscalar- the scalar multiplier- Returns:
- a new array containing the scaled values
- Throws:
NullPointerException- ifvectorisnull
-
addVectors
public static double[] addVectors(double[]... vectors) Adds one or more array-based vectors element by element.This utility is for array-based vector data, not necessarily for 3D geometry vectors. All arrays must have the same length.
- Parameters:
vectors- the arrays to add- Returns:
- a new array containing the element-wise sum
- Throws:
IllegalArgumentException- if no arrays are supplied or if the arrays do not all have the same lengthNullPointerException- ifvectorsor any array in it isnull
-