Class NumericalMethods


  • public class NumericalMethods
    extends Object
    Created by Karel Maesen, Geovise BVBA on 01/03/15.
    • Constructor Detail

      • NumericalMethods

        public NumericalMethods()
    • Method Detail

      • determinant

        public static double determinant​(double a11,
                                         double a12,
                                         double a21,
                                         double a22)
        Calculates the determinant of a 2x2 matrix
        Parameters:
        a11 -
        a12 -
        a21 -
        a22 -
        Returns:
        the determinant
      • crossProduct

        public static double crossProduct​(double x0,
                                          double y0,
                                          double x1,
                                          double y1)
      • determinant

        public static double determinant​(double a11,
                                         double a12,
                                         double a13,
                                         double a21,
                                         double a22,
                                         double a23,
                                         double a31,
                                         double a32,
                                         double a33)
        Calculates the determinant of a 3x3 matrix
        Parameters:
        a11 -
        a12 -
        a13 -
        a21 -
        a22 -
        a23 -
        a31 -
        a32 -
        a33 -
        Returns:
      • isCounterClockwise

        public static boolean isCounterClockwise​(Position p0,
                                                 Position p1,
                                                 Position p2)
        Determines if the triangle determined by p0, p1, p2 is counterclockwise in 2D.

        This is equivalent to p2 is to the left of the line p0 - p1.

        Parameters:
        p0 -
        p1 -
        p2 -
        Returns:
        true if counterclockwise
      • area

        public static double area​(LinearRing<?> ring)
        Determine the (signed) area of a linearring, using the the Shoelace algorithm.
        Parameters:
        ring -
        Returns:
      • isCounterClockwise

        public static boolean isCounterClockwise​(LinearRing<?> ring)
        Determines whether the specified LinearRing is counter-clockwise.

        Orientation is determined by calculating the signed area of the given ring and using the sign to determine the orientation

        The specified Ring is assumed to be valid.

        Parameters:
        ring - a LinearRing
        Returns:
        true if the positions of the ring describe it counter-clockwise
      • orient2d

        public static double orient2d​(LinearRing<?> ring)
        Determine the orientation of a LinearRing This uses Newell's method (see Graphics Gems III, V. 5)
        Parameters:
        ring - the linear ring
        Returns:
        +1 if the specified ring is clockwise, -1 if counterclockwise, 0 if all vertices are collinear