public class LineCrossDetector
extends java.lang.Object
Constructor and Description |
---|
LineCrossDetector() |
Modifier and Type | Method and Description |
---|---|
static boolean |
linesCross(com.google.android.gms.maps.model.LatLng firstStart,
com.google.android.gms.maps.model.LatLng firstEnd,
com.google.android.gms.maps.model.LatLng secondStart,
com.google.android.gms.maps.model.LatLng secondEnd)
Determines whether two lines cross.
|
public static boolean linesCross(com.google.android.gms.maps.model.LatLng firstStart, com.google.android.gms.maps.model.LatLng firstEnd, com.google.android.gms.maps.model.LatLng secondStart, com.google.android.gms.maps.model.LatLng secondEnd)
Crossing is not always the same as intersecting. Lines that share a tip intersect but do not cross for purposes of this function. However, a line that has an endpoint on the middle of another line must be considered to cross that line (to prevent circumventing the snake rule).
For simplicity, longitude and latitude are treated as X and Y, respectively, on a 2D coordinate plane. This ignores the roundness of the earth, but it's undetectable at reasonable scales of the game.
All parameters are assumed to be valid: both lines have positive length.
firstStart
- an endpoint of one linefirstEnd
- the other endpoint of that linesecondStart
- an endpoint of another linesecondEnd
- the other endpoint of that other line