org.kaboum.algorithm
Class KaboumAlgorithms

java.lang.Object
  extended by org.kaboum.algorithm.KaboumAlgorithms

public class KaboumAlgorithms
extends java.lang.Object


Constructor Summary
KaboumAlgorithms()
           
 
Method Summary
static double area2(KaboumCoordinate a, KaboumCoordinate b, KaboumCoordinate c)
          Compute the magnitude of the cross Product between two Vectors AB and AC.
static boolean autoIntersect(KaboumCoordinate[] internals)
          First point and last point MUST be different
static int computeOrientation(KaboumCoordinate p1, KaboumCoordinate p2, KaboumCoordinate q)
           
static double distance(KaboumCoordinate a, KaboumCoordinate b)
          Compute the Euclidian distance between to point.
static double distance(KaboumCoordinate p, KaboumCoordinate[] internals)
          Compute the distance between a point P and a PolyLine [A1...An].
static double distance(KaboumCoordinate p, KaboumCoordinate a, KaboumCoordinate b)
          Compute the distance between a point P and a segment [AB].
static double distance(KaboumCoordinate p, KaboumGeometry geometry)
          Return the distance between a point and a geometry
static boolean doesPointBorderGeometry(KaboumCoordinate p, KaboumGeometry geometry, double precision)
          Check if a point is on the border of a GEOMETRY
static boolean doesPointLieInGeometry(KaboumCoordinate p, KaboumGeometry geometry, double precision)
          Check if a point lies in or near a GEOMETRY
static boolean geometryIntersectsOther(KaboumGeometryGlobalDescriptor ggd, KaboumGeometryGlobalDescriptor[] ggds)
          Check if a geometry intersects other geometries.
static boolean geometryIsInsideOther(KaboumGeometryGlobalDescriptor ggd, KaboumGeometryGlobalDescriptor[] ggds)
          Check if a geometry is inside other geometries.
static boolean geometryIsValid(KaboumGeometry geometry)
          Check that a geometry does not intersect with itself.
static boolean geometrySurroundsOther(KaboumGeometryGlobalDescriptor ggd, KaboumGeometryGlobalDescriptor[] ggds)
          Check if a geometry surrounds other geometries.
static int getClosestPointPosition(KaboumCoordinate[] internals, KaboumCoordinate coord)
          Return the position of the closest vertex from an input Coordinate
static boolean inside(KaboumLineString ring1, KaboumLineString ring2)
          Return true if ring2 is inside ring1
static boolean intersect(KaboumCoordinate a, KaboumCoordinate b, KaboumCoordinate c, KaboumCoordinate d)
          Return true if segment [ab] intersects segment [cd]
static boolean intersect(KaboumLineString ring1, KaboumLineString ring2)
          Return true if ring1 and ring2 intersect
static boolean isBetweenAndNotColinear(KaboumCoordinate a, KaboumCoordinate b, KaboumCoordinate c)
           
static boolean isCCW(KaboumCoordinate[] ring)
          This class is a rewrite of isCCW(Coordinate[] ring) from JTS RobustCGAlgorithms class (cf. http://www.vividsolutions.com)
static boolean isColinear(KaboumCoordinate a, KaboumCoordinate b, KaboumCoordinate c)
          Determine if a point c is colinear with segment [ab].
static boolean isLeft(KaboumCoordinate a, KaboumCoordinate b, KaboumCoordinate c)
          Determine if a point c is to the left of segment [ab].
static boolean isPointInPolygon(KaboumCoordinate p, KaboumCoordinate[] ring)
          This algorithm does not attempt to first check the point against the envelope of the ring.
static boolean isPointInPolygon(KaboumCoordinate p, KaboumGeometry geometry)
          Check if a point is inside a GEOMETRY
static int orientationIndex(KaboumCoordinate p1, KaboumCoordinate p2, KaboumCoordinate q)
          This class is a rewrite of orientationIndex(Coordinate p1, Coordinate p2, Coordinate q) from JTS RobustCGAlgorithms class (cf. http://www.vividsolution.com)
static int signOfDet2x2(double x1, double y1, double x2, double y2)
          RobustDeterminant implements an algorithm to compute the sign of a 2x2 determinant for double precision values robustly.
static boolean xor(boolean x, boolean y)
          Exclusive or: true if exactly one argument is true (From: "Computational Geometry in C" by Joseph O'Rourke)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KaboumAlgorithms

public KaboumAlgorithms()
Method Detail

orientationIndex

public static int orientationIndex(KaboumCoordinate p1,
                                   KaboumCoordinate p2,
                                   KaboumCoordinate q)
This class is a rewrite of orientationIndex(Coordinate p1, Coordinate p2, Coordinate q) from JTS RobustCGAlgorithms class (cf. http://www.vividsolution.com)


isCCW

public static boolean isCCW(KaboumCoordinate[] ring)
This class is a rewrite of isCCW(Coordinate[] ring) from JTS RobustCGAlgorithms class (cf. http://www.vividsolutions.com)


doesPointLieInGeometry

public static boolean doesPointLieInGeometry(KaboumCoordinate p,
                                             KaboumGeometry geometry,
                                             double precision)
Check if a point lies in or near a GEOMETRY


doesPointBorderGeometry

public static boolean doesPointBorderGeometry(KaboumCoordinate p,
                                              KaboumGeometry geometry,
                                              double precision)
Check if a point is on the border of a GEOMETRY


isPointInPolygon

public static boolean isPointInPolygon(KaboumCoordinate p,
                                       KaboumGeometry geometry)
Check if a point is inside a GEOMETRY


isPointInPolygon

public static boolean isPointInPolygon(KaboumCoordinate p,
                                       KaboumCoordinate[] ring)
This algorithm does not attempt to first check the point against the envelope of the ring. This class is a rewrite of isPointInPolygon(Coordinate p, Coordinate[] ring) method from JTS RobustCGAlgorithms class (cf. http://www.vividsolutions.com)

Parameters:
ring - assumed to have first point identical to last point

computeOrientation

public static int computeOrientation(KaboumCoordinate p1,
                                     KaboumCoordinate p2,
                                     KaboumCoordinate q)

distance

public static double distance(KaboumCoordinate p,
                              KaboumGeometry geometry)
Return the distance between a point and a geometry


distance

public static double distance(KaboumCoordinate p,
                              KaboumCoordinate[] internals)
Compute the distance between a point P and a PolyLine [A1...An].

Parameters:
p - Point P
polyLine - PolyLine (Polygon representation)
Returns:
The square distance between the point and the polyline.

distance

public static double distance(KaboumCoordinate p,
                              KaboumCoordinate a,
                              KaboumCoordinate b)
Compute the distance between a point P and a segment [AB].

Parameters:
p - Point P
a - Point A
b - Point B
Returns:
The distance between the point and the segment.

area2

public static double area2(KaboumCoordinate a,
                           KaboumCoordinate b,
                           KaboumCoordinate c)
Compute the magnitude of the cross Product between two Vectors AB and AC. The magnitude of the cross product is twice the area of the triangle they determine. (From: "Computational Geometry in C" by Joseph O'Rourke) (Image coordinates version)

Parameters:
a - Point A
b - Point B
c - Point C

distance

public static double distance(KaboumCoordinate a,
                              KaboumCoordinate b)
Compute the Euclidian distance between to point.


signOfDet2x2

public static int signOfDet2x2(double x1,
                               double y1,
                               double x2,
                               double y2)
RobustDeterminant implements an algorithm to compute the sign of a 2x2 determinant for double precision values robustly. It is a direct translation of code developed by Olivier Devillers.

The original code carries the following copyright notice:


 Author : Olivier Devillers
 Olivier.Devillers@sophia.inria.fr
 http:/www.inria.fr:/prisme/personnel/devillers/anglais/determinant.html



              Copyright (c) 1995  by  INRIA Prisme Project
                  BP 93 06902 Sophia Antipolis Cedex, France.
                           All rights reserved

 


getClosestPointPosition

public static int getClosestPointPosition(KaboumCoordinate[] internals,
                                          KaboumCoordinate coord)
Return the position of the closest vertex from an input Coordinate

Parameters:
internals - Vertices list
coord - Input coordinate (internal representation)

isBetweenAndNotColinear

public static boolean isBetweenAndNotColinear(KaboumCoordinate a,
                                              KaboumCoordinate b,
                                              KaboumCoordinate c)

isColinear

public static boolean isColinear(KaboumCoordinate a,
                                 KaboumCoordinate b,
                                 KaboumCoordinate c)
Determine if a point c is colinear with segment [ab]. This is true if the area of triangle (a,b,c) is null. (From: "Computational Geometry in C" by Joseph O'Rourke) (Image coordinates version)

Parameters:
a - Point a
b - Point b
c - Point c

isLeft

public static boolean isLeft(KaboumCoordinate a,
                             KaboumCoordinate b,
                             KaboumCoordinate c)
Determine if a point c is to the left of segment [ab]. This is true if the area of triangle (a,b,c) is positive (From: "Computational Geometry in C" by Joseph O'Rourke) (Image coordinates version)

Parameters:
a - Point a
b - Point b
c - Point c

autoIntersect

public static boolean autoIntersect(KaboumCoordinate[] internals)
First point and last point MUST be different


intersect

public static boolean intersect(KaboumCoordinate a,
                                KaboumCoordinate b,
                                KaboumCoordinate c,
                                KaboumCoordinate d)
Return true if segment [ab] intersects segment [cd]


intersect

public static boolean intersect(KaboumLineString ring1,
                                KaboumLineString ring2)
Return true if ring1 and ring2 intersect


inside

public static boolean inside(KaboumLineString ring1,
                             KaboumLineString ring2)
Return true if ring2 is inside ring1


xor

public static boolean xor(boolean x,
                          boolean y)
Exclusive or: true if exactly one argument is true (From: "Computational Geometry in C" by Joseph O'Rourke)

Parameters:
x - Condition 1
y - Condition 2

geometryIsValid

public static boolean geometryIsValid(KaboumGeometry geometry)
Check that a geometry does not intersect with itself. Algorithm always returns true for Point, MultiPoint, LineString and MultiLineString. For Polygon and MultiPolygon geometries, algorithm checks each exterior and interior ring. Algorithm returns false if (in order): 1. one of the exterior or interior rings intersect with itself 2. exterior ring intersects or is inside another exterior ring 3. interior ring intersects or is ouside from it exterior ring 4. interior ring intersects another interior ring within the same exterior ring


geometrySurroundsOther

public static boolean geometrySurroundsOther(KaboumGeometryGlobalDescriptor ggd,
                                             KaboumGeometryGlobalDescriptor[] ggds)
Check if a geometry surrounds other geometries. Algorithm only checks for Polygon and MultiPolygon geometries. Algorithm returns false if : 1. geometry does not surround other polygonals geometries 2. geometry is not a Polygon or MultiPolygon


geometryIntersectsOther

public static boolean geometryIntersectsOther(KaboumGeometryGlobalDescriptor ggd,
                                              KaboumGeometryGlobalDescriptor[] ggds)
Check if a geometry intersects other geometries. Algorithm only checks for Polygon and MultiPolygon geometries. Algorithm returns false if : 1. geometry does not intersect other polygonals geometries 2. geometry is not a Polygon or MultiPolygon


geometryIsInsideOther

public static boolean geometryIsInsideOther(KaboumGeometryGlobalDescriptor ggd,
                                            KaboumGeometryGlobalDescriptor[] ggds)
Check if a geometry is inside other geometries. Algorithm only checks for Polygon and MultiPolygon geometries. Algorithm returns false if : 1. geometry is not inside other polygonals geometries 2. geometry is not a Polygon or MultiPolygon



Copyright © 2005 Kaboum team. All Rights Reserved.