Package org.geolatte.geom.cga
Class NumericalMethods
- java.lang.Object
-
- org.geolatte.geom.cga.NumericalMethods
-
public class NumericalMethods extends Object
Created by Karel Maesen, Geovise BVBA on 01/03/15.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNumericalMethods.TwoSum
-
Constructor Summary
Constructors Constructor Description NumericalMethods()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublearea(LinearRing<?> ring)Determine the (signed) area of a linearring, using the the Shoelace algorithm.static booleancollinear(Position p0, Position p1, Position p2)static doublecrossProduct(double x0, double y0, double x1, double y1)static doubledeterminant(double a11, double a12, double a21, double a22)Calculates the determinant of a 2x2 matrixstatic doubledeterminant(double a11, double a12, double a13, double a21, double a22, double a23, double a31, double a32, double a33)Calculates the determinant of a 3x3 matrixstatic doubledeterminant(Position p0, Position p1)static booleanisCounterClockwise(LinearRing<?> ring)Determines whether the specifiedLinearRingis counter-clockwise.static booleanisCounterClockwise(Position p0, Position p1, Position p2)Determines if the triangle determined by p0, p1, p2 is counterclockwise in 2D.static doubleorient2d(LinearRing<?> ring)Determine the orientation of aLinearRingThis uses Newell's method (see Graphics Gems III, V.
-
-
-
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 specifiedLinearRingis 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- aLinearRing- Returns:
- true if the positions of the ring describe it counter-clockwise
-
orient2d
public static double orient2d(LinearRing<?> ring)
Determine the orientation of aLinearRingThis 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
-
-