Class GeoUtil

java.lang.Object
edu.cnu.mdi.geometry.GeoUtil

public final class GeoUtil extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Effectively zero for parallelism, degeneracy, and normalization tests.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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 boolean
    tiny(double v)
    Tests whether a value is effectively zero.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TINY

      public static final double TINY
      Effectively 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:
      true if abs(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 multiply
      scalar - the scalar multiplier
      Returns:
      a new array containing the scaled values
      Throws:
      NullPointerException - if vector is null
    • 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 length
      NullPointerException - if vectors or any array in it is null