com.bbn.openmap.geo
Class Intersection

java.lang.Object
  |
  +--com.bbn.openmap.geo.Intersection

public class Intersection
extends java.lang.Object

Contains great circle intersection algorithms and helper methods. Sources:

 
  http://williams.best.vwh.net/intersect.htm
  http://mathforum.org/library/drmath/view/60711.html
  
 


Constructor Summary
Intersection()
           
 
Method Summary
static float[] getIntersection(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4)
          Returns the two antipodal points of interection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4).
static float[] getSegIntersection(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4)
          Returns the point of intersection of two great circle segments defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4).
static float greatCircleDistance(float lat1, float lon1, float lat2, float lon2)
          Calculates the great circle distance between the two lat, lon points.
static boolean intersects(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4)
          Returns true if the two segs intersect in at least one point.
static boolean intersectsCircle(float[] polyPoints, float lat, float lon, float radius)
          Returns true if the specified poly path intersects the circle centered at (lat, lon).
static boolean intersectsCircle(float lat1, float lon1, float lat2, float lon2, float lat, float lon, float radius)
          Returns true or false depending on whether the great circle seg from point (lat1, lon1) to (lat2, lon2) intersects the circle of radius centered at point (lat, lon).
static boolean isSelfIntersectingPoly(float[] polyPoints)
          Checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other.
static void main(java.lang.String[] args)
           
static float pointCircleDistance(float lat1, float lon1, float lat2, float lon2, float lat, float lon)
          Calculates the great circle distance from the point (lat, lon) to the great circle containing the points (lat1, lon1) and (lat2, lon2).
static boolean polyIntersect(float[] polyPoints1, float[] polyPoints2)
          Checks if the two polygonal areas intersect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Intersection

public Intersection()
Method Detail

getIntersection

public static float[] getIntersection(float lat1,
                                      float lon1,
                                      float lat2,
                                      float lon2,
                                      float lat3,
                                      float lon3,
                                      float lat4,
                                      float lon4)
Returns the two antipodal points of interection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
an array of two lat-lon points arranged as lat, lon, lat, lon

getSegIntersection

public static float[] getSegIntersection(float lat1,
                                         float lon1,
                                         float lat2,
                                         float lon2,
                                         float lat3,
                                         float lon3,
                                         float lat4,
                                         float lon4)
Returns the point of intersection of two great circle segments defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
a float array of length 4 containing upto 2 valid lat-lon points of intersection that lie on both segments. Positions in the array not containing a valid lat/lon value are initialized to Float.MAX_VALUE.

intersects

public static boolean intersects(float lat1,
                                 float lon1,
                                 float lat2,
                                 float lon2,
                                 float lat3,
                                 float lon3,
                                 float lat4,
                                 float lon4)
Returns true if the two segs intersect in at least one point. All lat-lon values are in degrees.


polyIntersect

public static boolean polyIntersect(float[] polyPoints1,
                                    float[] polyPoints2)
Checks if the two polygonal areas intersect. The two polygonal regions are represented by two lat-lon arrays in the lat1, lon1, lat2, lon2,... format. For closed polygons the last pair of points in the array should be the same as the first pair. All lat-lon values are in degrees.


isSelfIntersectingPoly

public static boolean isSelfIntersectingPoly(float[] polyPoints)
Checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other. All lat-lon values are in degrees.


pointCircleDistance

public static float pointCircleDistance(float lat1,
                                        float lon1,
                                        float lat2,
                                        float lon2,
                                        float lat,
                                        float lon)
Calculates the great circle distance from the point (lat, lon) to the great circle containing the points (lat1, lon1) and (lat2, lon2).
All lat-lon values are in degrees.

Returns:
distance in radians.

intersectsCircle

public static boolean intersectsCircle(float lat1,
                                       float lon1,
                                       float lat2,
                                       float lon2,
                                       float lat,
                                       float lon,
                                       float radius)
Returns true or false depending on whether the great circle seg from point (lat1, lon1) to (lat2, lon2) intersects the circle of radius centered at point (lat, lon). All lat-lon values are in degrees, radius is in radians.


intersectsCircle

public static boolean intersectsCircle(float[] polyPoints,
                                       float lat,
                                       float lon,
                                       float radius)
Returns true if the specified poly path intersects the circle centered at (lat, lon). All lat-lon values are in degrees, radius is in radians.


greatCircleDistance

public static float greatCircleDistance(float lat1,
                                        float lon1,
                                        float lat2,
                                        float lon2)
Calculates the great circle distance between the two lat, lon points. All lat-lon values are in degrees.


main

public static void main(java.lang.String[] args)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details