Class TLcdSphereUtil
TLcdSphereUtil
is a utility class that implements spherical
trigonometry. All implementations are based on a sphere with a unity radius.
All results are in arc degrees.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
arcContains2D
(ILcdArc aArc, double aSphereRadius, ILcdPoint aLLPoint) Checks whether the pointaLLPoint
lies on the elliptical arc segment.static boolean
arcContains2D
(ILcdPoint aCenter, double aMajorAxe, double aMinorAxe, double aRotAngle, double aStartAngle, double aArcAngle, double aSphereRadius, ILcdPoint aLLPoint) Checks whether the pointaLLPoint
lies on the elliptical arc segment.static double
arcDegreesToMeters
(double aArcDegreeDistance, double aSphereRadius) Converts the given distance of the given arc into a distance in meters, using the given sphere radius.static void
bufferContour2DOf2DPolyline
(ILcdPointList aPointList, double aWidth, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the buffer/corridor along a givenILcdPointList
at a given width.static void
bufferContour2DOfSegmentSFCT
(ILcdPoint aStartPoint, ILcdPoint aEndPoint, double aWidth, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the rectangle defined byaStartPoint
,aEndPoint
, andaWidth
, as an array of 4ILcd2DEditablePoint
objects.static void
calculateBounds
(ILcdPointList aPointList, boolean aPolygon, ILcd2DEditableBounds aBoundsSFCT) Calculates the bounding box containing the polyline/polygon formed by the point list assuming great circle line segments.static boolean
circleContains2D
(ILcdPoint aCenter, double aCircleRadius, double aSphereRadius, ILcdPoint aPoint) Checks whether the pointaPoint
lies within the circle(aCenter,aCircleRadius)
on the sphere with radiusaSphereRadius
.static double
closestDistanceToGeodesic
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, boolean aClipToLineSegment) Calculates the shortest distance between the geodetic line (segment)aP1-aP2
and pointaP3
.static double
closestPointOnGeodesic
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, boolean aClipToLineSegment, ILcd2DEditablePoint aPSFCT) Calculates the shortest distance between the geodesic throughaP1-aP2
and the pointaP3
, and also the point on the geodesicaP1-aP2
that is the closest to point aP3.static double
closestPointOnGeodesic
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcd2DEditablePoint aPSFCT) Calculates the shortest distance between the geodesic line segmentaP1-aP2
and pointaP3
, and also the point on the geodesicaP1-aP2
that is the closest to point aP3.static double
closestPointOnShape
(ILcdPoint aPoint, ILcdShape aShape, ILcd2DEditablePoint aResultSFCT) Finds the shortest distance from the given point to the given shape.static boolean
contains2D
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aPoint) Checks whether the pointaPoint
lies on the geodesic line segmentaP1-aP2
.static boolean
contains2DLS
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4) Checks if the line segmentaP1-aP2
contains the line segmentaP3-aP4
.static boolean
contains2DSR
(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether a 2D rectangle contains another rectangle.static void
contour2DOfBoundsSFCT
(ILcdBounds aBounds, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the givenILcdBounds
, as an array ofILcd2DEditablePoint
objects.static double
distanceToGeodesic
(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aAngle) Calculates the distance between the geodesic line through(aLon1,aLat1)-(aLon2,aLat2)
and point(aLon3,aLat3)
, at a certain angleaAngle
.static double
distanceToGeodesic
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, double aAngle) Calculates the distance between the geodesic line determined byaP1-aP2
and the pointaP3
, at a certain angleaAngle
.static double
forwardAzimuth2D
(ILcdPoint aP1, ILcdPoint aP2) Forward azimuth fromaP1
toaP2
in RADIANS! The resulting value lies between [0.0, 2.0*Math.PI].static void
geoc2llhSFCT
(ILcdPoint aXYZPoint, double aRadius, ILcd3DEditablePoint aLLHOut) Coordinate conversion from earth centered, earth fixed cartesian coordinates (X,Y,Z) to geodetic coordinate(l, j ,h )
, with h the height above the sphere.static double
geodesicArea
(ILcdPoint[] aPts, int aN) Geodesic surface area of a polygon on the sphere.static double
geodesicArea
(ILcdPoint[] aPts, int aN, double aRadius) Geodesic surface area of a polygon on the sphere.static double
geodesicArea
(ILcdShape aShape, double aRadius) Calculates the geodesic area of a shape.static double
greatCircleDistance
(double aLon1, double aLat1, double aLon2, double aLat2) Great circle distance fromaP1
toaP2
in arc degrees !static double
greatCircleDistance
(double aLon1, double aLat1, double aCosLat1, double aLon2, double aLat2, double aCosLat2) Great circle distance fromaP1
toaP2
in arc degrees !static double
greatCircleDistance
(ILcdPoint aP1, ILcdPoint aP2) Calculates the shortest distance betweenaP1
andaP2
.static double
greatCircleDistance3D
(ILcdPoint aPoint1, ILcdPoint aPoint2, double aRadius) Calculates the distance to go from point p1 to point p2.static double
greatCircleDistanceEast2West
(double aLon1, double aLat1, double aLon2, double aLat2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from east to west.static double
greatCircleDistanceEast2West
(ILcdPoint aP1, ILcdPoint aP2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from east to west.static double
greatCircleDistanceWest2East
(double aLon1, double aLat1, double aLon2, double aLat2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from west to east.static double
greatCircleDistanceWest2East
(ILcdPoint aP1, ILcdPoint aP2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from west to east.static void
greatCirclePointSFCT
(ILcdPoint aP1, double aDistance, double aAzimuth, ILcd2DEditablePoint aGreatCirclePoint) CalculatesaGreatCirclePoint
to be a point on the great circle throughaP1
, located at a distanceaD
and forward azimuthaAzimuth
.static void
greatCirclePointSFCT
(ILcdPoint aP1, ILcdPoint aP2, double aK, ILcd2DEditablePoint aGreatCirclePoint) CalculatesaGreatCirclePoint
to be a point on the great circle throughaP1
andaP2
, located at a fractionaK
of the shortest distance between the two pointaP1
andaP2
.static int
intersection2DLineSegments
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT1, ILcd2DEditablePoint aLLResultSFCT2) Intersection of two geodesic line segments on a sphere.static void
intersection2DLSSFCT
(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4, ILcd2DEditablePoint aLLP) Deprecated.static void
intersection2DLSSFCT
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT) Deprecated.the name of this method contradicts the actual behavior, useintersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
static int
intersection2DLSSFCT
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT1, ILcd2DEditablePoint aLLResultSFCT2) Deprecated.the name of this method contradicts the actual behavior, useintersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
static void
intersectionGeodesicGeodesic
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT) Calculates the intersection point of two great circle lines (geodesics) defined by the given points.static boolean
intersects2DCircleLineSegment
(ILcdPoint aCenter, double aRadius, ILcdPoint aP1, ILcdPoint aP2) Checks whether a circle and a line segment intersect each other.static boolean
intersects2DCircularArcCircularArc
(ILcdPoint aCenter1, double aRadius1, double aStartAngle1, double aArcAngle1, ILcdPoint aCenter2, double aRadius2, double aStartAngle2, double aArcAngle2) Checks whether two circular arcs intersect each other.static boolean
intersects2DLineSegmentCircularArc
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aCenter, double aRadius, double aStartAngle, double aArcAngle) Checks whether a line segment and a circular arc segment intersect each other.static boolean
intersects2DLineSegments
(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4) Checks whether two geodesic line segments defined by the pairs(aLon1,aLat1)-(aLon2,aLat2)
and(aLon3,aLat3)-(aLon4,aLat4)
intersect each other.static boolean
intersects2DLineSegments
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4) Checks whether two geodesic line segments defined by the pairsaP1-aP2
andaP3-aP4
intersect each other.static boolean
intersects2DLS
(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4) Checks whether two geodesic line segments defined by the pairs(aLon1,aLat1)-(aLon2,aLat2)
and(aLon3,aLat3)-(aLon4,aLat4)
intersect each other.static boolean
intersects2DLS
(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4) Checks whether two geodesic line segments defined by the pairsaP1-aP2
andaP3-aP4
intersect each other.static boolean
intersects2DSR
(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles intersect.static void
llh2geocSFCT
(ILcdPoint aLLHPoint, double aRadius, ILcd3DEditablePoint aXYZOut) Coordinate conversion from geodetic coordinate(l, j ,h )
to earth centered, earth fixed Cartesian coordinates (X,Y,Z) .static double
metersToArcDegrees
(double aDistance, double aSphereRadius) Converts the given distance in meters into a distance in arc degrees, using the given sphere radius.static int
orientation2D
(ILcdPoint[] aPoints, int aNumberOfPoints) Calculates the orientation of an array of points on a sphere.static int
orientation2D
(ILcdPointList aPointList) Calculates the orientation of a point list on a sphere.static boolean
overlaps2DSR
(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles overlap.static boolean
overlaps2DSRLowLeft
(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles overlap.static boolean
polygonContains2D
(ILcdPolygon aPolygon, double aLonP, double aLatP) Checks if a point lies inside a polygon.static boolean
polygonContains2D
(ILcdPolygon aPolygon, ILcdPoint aPoint) Checks if a point lies inside a polygon.
-
Constructor Details
-
TLcdSphereUtil
public TLcdSphereUtil()
-
-
Method Details
-
metersToArcDegrees
public static double metersToArcDegrees(double aDistance, double aSphereRadius) Converts the given distance in meters into a distance in arc degrees, using the given sphere radius.- Parameters:
aDistance
- the distance in metersaSphereRadius
- the radius of the underlying sphere- Returns:
- a distance on the sphere in degrees
-
arcDegreesToMeters
public static double arcDegreesToMeters(double aArcDegreeDistance, double aSphereRadius) Converts the given distance of the given arc into a distance in meters, using the given sphere radius.- Parameters:
aArcDegreeDistance
- a distance on the sphere in degreesaSphereRadius
- the radius of the underlying sphere- Returns:
- the distance in meters
-
greatCircleDistance
Calculates the shortest distance betweenaP1
andaP2
. As a result, the difference will never exceed 180 degrees !- Parameters:
aP1
- first point.aP2
- second point.- Returns:
- The distance between the two points (in degrees).
-
greatCircleDistance
public static double greatCircleDistance(double aLon1, double aLat1, double aLon2, double aLat2) Great circle distance fromaP1
toaP2
in arc degrees !- Parameters:
aLon1
- longitude of the first point in degrees.aLat1
- latitude of the first point in degrees.aLon2
- longitude of the second point in degrees.aLat2
- latitude of the second point in degrees.- Returns:
- The distance between the two points (in degrees).
-
greatCircleDistance
public static double greatCircleDistance(double aLon1, double aLat1, double aCosLat1, double aLon2, double aLat2, double aCosLat2) Great circle distance fromaP1
toaP2
in arc degrees !- Parameters:
aLon1
- longitude of start point of line segment in degrees.aLat1
- latitude of start point of line segment in degrees.aCosLat1
- cosine of the latitude of the start point.aLon2
- longitude of end point of line segment in degrees.aLat2
- latitude of end point of line segment in degrees.aCosLat2
- cosine of the latitude of the end point.- Returns:
- the distance in degrees.
-
distanceToGeodesic
Calculates the distance between the geodesic line determined byaP1-aP2
and the pointaP3
, at a certain angleaAngle
. Returns result in degrees.- Parameters:
aP1
- defining point of geodesic line.aP2
- defining point of geodesic line.aP3
- point from which the distance needs to be calculated.aAngle
- defines the angle between the geodesic lines defined by the pointaP3
and the point of crossing and the geodesic line defined byaP1
andaP2
and the point of crossing. Should be specified in degrees.- Returns:
- the distance in degrees.
-
distanceToGeodesic
public static double distanceToGeodesic(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aAngle) Calculates the distance between the geodesic line through(aLon1,aLat1)-(aLon2,aLat2)
and point(aLon3,aLat3)
, at a certain angleaAngle
. Returns result in degrees.- Parameters:
aLon1
- longitude of defining point of geodesic line in degrees.aLat1
- latitude of defining point of geodesic line in degrees.aLon2
- longitude of defining point of geodesic line in degrees.aLat2
- latitude of defining point of geodesic line in degrees.aLon3
- longitude of third point in degrees.aLat3
- latitude of third point in degrees.aAngle
- defines the angle between the geodesic defined by(aLon3,aLat3)
and the point of crossing and the geodesic defined by(aLon2,aLat2)
and the point of crossing.- Returns:
- the distance in degrees.
-
closestDistanceToGeodesic
public static double closestDistanceToGeodesic(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, boolean aClipToLineSegment) Calculates the shortest distance between the geodetic line (segment)aP1-aP2
and pointaP3
.- Parameters:
aP1
- start point of the geodesic.aP2
- end point of the geodesic.aP3
- point from which the distance has to be calculated.aClipToLineSegment
- iffalse
, the shortest distance will be calculated for the whole geodesic. Otherwise it will only be calculated for the geodesic line segmentaP1-aP2
.- Returns:
- the distance in degrees.
-
closestPointOnShape
public static double closestPointOnShape(ILcdPoint aPoint, ILcdShape aShape, ILcd2DEditablePoint aResultSFCT) Finds the shortest distance from the given point to the given shape. The corresponding point on the shape is returned in the side effect parameter.This methods supports
geodetic
andrhumb
ILcdPolyline
andILcdPolygon
instances.- Parameters:
aPoint
- the starting pointaShape
- the shape for which to find the point closest to aPointaResultSFCT
- side-effect parameter for the resulting point- Returns:
- the shortest distance in degrees
- Throws:
IllegalArgumentException
- if the provided shape is not supported
-
closestPointOnGeodesic
public static double closestPointOnGeodesic(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcd2DEditablePoint aPSFCT) Calculates the shortest distance between the geodesic line segmentaP1-aP2
and pointaP3
, and also the point on the geodesicaP1-aP2
that is the closest to point aP3.- Parameters:
aP1
- start point of geodesic.aP2
- end point of geodesic.aP3
- point from which the distance has to be calculated.aPSFCT
- point that will contain the coordinate of the point on the geodesic line segmentaP1-aP2
that is calculated to be at the shortest distance toaP3
.- Returns:
- the distance in degrees.
-
closestPointOnGeodesic
public static double closestPointOnGeodesic(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, boolean aClipToLineSegment, ILcd2DEditablePoint aPSFCT) Calculates the shortest distance between the geodesic throughaP1-aP2
and the pointaP3
, and also the point on the geodesicaP1-aP2
that is the closest to point aP3. The flagaClipToLineSegment
determines whether the geodesic is to be considered as the geodesic line segment defined by the two points or as the geodesic line through the two points.- Parameters:
aP1
- start point of geodesic.aP2
- end point of geodesic.aP3
- point from which the distance has to be calculated.aClipToLineSegment
- Description of ParameteraPSFCT
- point that will contain the coordinate of the point on the geodesic throughaP1-aP2
that is calculated to be at the shortest distance toaP3
. This point may be clipped onto the line segment depending on the value ofaClipToLineSegment
.- Returns:
- the distance in degrees.
-
geodesicArea
Geodesic surface area of a polygon on the sphere.Constraints: (
aN > 2
) and (aPts.length >= aN
).- Parameters:
aPts
- array ofILcdPoint
objects.aN
-aPts[0..aN-1]
defines the polygon on the sphere.- Returns:
- the surface area in radians2. Positive for counterclockwise polygons, negative otherwise.
-
geodesicArea
Geodesic surface area of a polygon on the sphere.Constraints: (
aN > 2
) and (aPts.length >= aN
).- Parameters:
aPts
- array ofILcdPoint
objects.aN
-aPts[0..aN-1]
defines the polygon on the sphere.aRadius
- radius of the sphere.- Returns:
- the surface area in meter2. Positive for counterclockwise polygons, negative otherwise.
- Since:
- 2022.0
-
geodesicArea
Calculates the geodesic area of a shape.Following shapes are supported:
ILcdPolygon
that doesn't self-intersectILcdComplexPolygon
that is geometrically valid: no individual polygon can be self-intersecting, and no two polygons may intersect. Nested polygons are allowed.ILcdSurface
with external and internal rings as polygons. The surface must also be geometrically valid.ILcdShapeList
containing supported shapes.
This method does not fully check the validity of the arguments, since it is computationally too expensive to do so. Passing an unsupported shape may result in an
IllegalArgumentException
being thrown, or may result in an undefined return value.- Parameters:
aShape
- a shape adhering to the requirements aboveaRadius
- radius of the sphere, in meter- Returns:
- the surface area in meter2, always positive
- Since:
- 2022.0
- See Also:
-
orientation2D
Calculates the orientation of an array of points on a sphere.Constraints: (
aNumberOfPoints
> 2) and (aPoints.length >= aNumberOfPoints
).- Parameters:
aPoints
- array ofILcdPoint
objects (first point is not repeated).aNumberOfPoints
- the number of points of the array to take into account.- Returns:
- the orientation of the polygon. Possible return values are ILcdPolygon#CLOCKWISE and ILcdPolygon#COUNTERCLOCKWISE.
-
orientation2D
Calculates the orientation of a point list on a sphere.Constraints: (
aPointList.length > 2
).- Parameters:
aPointList
- the point list to compute the orientation of. Note that this implies interpreting the point list as a polygon. The last point of the point list does not need to be equal to the first point.- Returns:
- the orientation of the polygon which would be described by the point list.
Possible return values are
ILcdPolygon.CLOCKWISE
andILcdPolygon.COUNTERCLOCKWISE
.
-
forwardAzimuth2D
Forward azimuth fromaP1
toaP2
in RADIANS! The resulting value lies between [0.0, 2.0*Math.PI]. See Maling p. 62.- Parameters:
aP1
- start point.aP2
- end point.- Returns:
- result in radians.
-
greatCirclePointSFCT
public static void greatCirclePointSFCT(ILcdPoint aP1, double aDistance, double aAzimuth, ILcd2DEditablePoint aGreatCirclePoint) CalculatesaGreatCirclePoint
to be a point on the great circle throughaP1
, located at a distanceaD
and forward azimuthaAzimuth
.- Parameters:
aP1
- startILcdPoint
on the sphere.aDistance
- distance expressed in arc degrees.aAzimuth
- azimuth expressed in degrees.aGreatCirclePoint
-ILcd2DEditablePoint
on the sphere as side effect.
-
greatCirclePointSFCT
public static void greatCirclePointSFCT(ILcdPoint aP1, ILcdPoint aP2, double aK, ILcd2DEditablePoint aGreatCirclePoint) CalculatesaGreatCirclePoint
to be a point on the great circle throughaP1
andaP2
, located at a fractionaK
of the shortest distance between the two pointaP1
andaP2
.- Parameters:
aP1
- start point of line segment.aP2
- end point of line segment.aK
- fraction of distance betweenaP1-aP2
to take.aGreatCirclePoint
- point at fractionaK
as side effect.
-
geoc2llhSFCT
Coordinate conversion from earth centered, earth fixed cartesian coordinates (X,Y,Z) to geodetic coordinate(l, j ,h )
, with h the height above the sphere.- Parameters:
aXYZPoint
- earth centered earth fixed cartesian coordinates (meters).aRadius
- radius of the sphere (meters).aLLHOut
- geodetic coordinate w.r.t. sphere, height expressed in meters.
-
llh2geocSFCT
Coordinate conversion from geodetic coordinate(l, j ,h )
to earth centered, earth fixed Cartesian coordinates (X,Y,Z) .- Parameters:
aLLHPoint
- Geodetic coordinate(l, j ,h )
.aRadius
- radius of the sphere.aXYZOut
- earth centered earth fixed cartesian coordinate.
-
greatCircleDistanceWest2East
Calculates the distance betweenaP1
andaP2
, tracing the sphere from west to east.- Parameters:
aP1
- start point of line segment.aP2
- end point of line segment.- Returns:
- distance in arc degrees.
-
greatCircleDistanceWest2East
public static double greatCircleDistanceWest2East(double aLon1, double aLat1, double aLon2, double aLat2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from west to east.- Parameters:
aLon1
- longitude of the start point of the line segment (in degrees).aLat1
- latitude of the start point of the line segment (in degrees).aLon2
- longitude of the end point of the line segment (in degrees).aLat2
- latitude of the end point of the line segment (in degrees).- Returns:
- distance in arc degrees.
-
greatCircleDistanceEast2West
Calculates the distance betweenaP1
andaP2
, tracing the sphere from east to west.- Parameters:
aP1
- start point of line segment.aP2
- end point of line segment.- Returns:
- distance in arc degrees.
-
greatCircleDistanceEast2West
public static double greatCircleDistanceEast2West(double aLon1, double aLat1, double aLon2, double aLat2) Calculates the distance betweenaP1
andaP2
, tracing the sphere from east to west.- Parameters:
aLon1
- longitude of the start point of the line segment (in degrees).aLat1
- latitude of the start point of the line segment (in degrees).aLon2
- longitude of the end point of the line segment (in degrees).aLat2
- latitude of the end point of the line segment (in degrees).- Returns:
- distance in arc degrees.
-
intersection2DLineSegments
public static int intersection2DLineSegments(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT1, ILcd2DEditablePoint aLLResultSFCT2) Intersection of two geodesic line segments on a sphere. The intersection point should lie on both line segments.- Parameters:
aP1
- start point of first line segment.aP2
- start point of first line segment.aP3
- end point of second line segment.aP4
- end point of second line segment.aLLResultSFCT1
- side effect parameter that will contain the intersection point if there is any.aLLResultSFCT2
- side effect parameter that will contain the intersection point if there is any.- Returns:
- the number of intersection points. Possible return codes are 0 if there is no intersection point, 1 if there is one intersection point, and -1 if the line segments overlap each other. In the latter case the two side effect parameters contain the start and end point of the overlapping interval.
-
intersects2DLS
Checks whether two geodesic line segments defined by the pairsaP1-aP2
andaP3-aP4
intersect each other.- Parameters:
aP1
- start point of first line segment.aP2
- end point of first line segment.aP3
- start point of second line segment.aP4
- end point of second line segment.- Returns:
- true if the two line segments have an intersection point, false otherwise.
- See Also:
-
intersects2DLS
public static boolean intersects2DLS(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4) Checks whether two geodesic line segments defined by the pairs(aLon1,aLat1)-(aLon2,aLat2)
and(aLon3,aLat3)-(aLon4,aLat4)
intersect each other.- Parameters:
aLon1
- longitude of start point of first line segment (in degrees).aLat1
- latitude of end point of first line segment (in degrees).aLon2
- longitude of start point of first line segment (in degrees).aLat2
- latitude of end point of first line segment (in degrees).aLon3
- longitude of start point of second line segment (in degrees).aLat3
- latitude of end point of second line segment (in degrees).aLon4
- longitude of start point of second line segment (in degrees).aLat4
- latitude of end point of second line segment (in degrees).- Returns:
- true if the two line segments have an intersection point, false otherwise.
-
intersects2DLineSegments
public static boolean intersects2DLineSegments(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4) Checks whether two geodesic line segments defined by the pairsaP1-aP2
andaP3-aP4
intersect each other.- Parameters:
aP1
- start point of first line segment.aP2
- start point of first line segment.aP3
- end point of second line segment.aP4
- end point of second line segment.- Returns:
- true if the two line segments have an intersection point that lies on both line segments, false otherwise.
- See Also:
-
intersects2DLineSegments
public static boolean intersects2DLineSegments(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4) Checks whether two geodesic line segments defined by the pairs(aLon1,aLat1)-(aLon2,aLat2)
and(aLon3,aLat3)-(aLon4,aLat4)
intersect each other.- Parameters:
aLon1
- longitude of start point of first line segment (in degrees).aLat1
- latitude of end point of first line segment (in degrees).aLon2
- longitude of start point of first line segment (in degrees).aLat2
- latitude of end point of first line segment (in degrees).aLon3
- longitude of start point of second line segment (in degrees).aLat3
- latitude of end point of second line segment (in degrees).aLon4
- longitude of start point of second line segment (in degrees).aLat4
- latitude of end point of second line segment (in degrees).- Returns:
- true if the two line segments have an intersection point that lies on both line segments, false otherwise.
- See Also:
-
intersection2DLSSFCT
@Deprecated public static void intersection2DLSSFCT(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT) throws IllegalArgumentException Deprecated.the name of this method contradicts the actual behavior, useintersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
Calculates the intersection point of two great circle lines (geodesics) defined by the given points. Seeintersection2DLineSegments(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
for calculating the intersection of line segments.Since great circle planes that do no coincide always have two intersection points, the most appropriate is chosen. If one of the two possibilities is on one of the line segments that one is chosen. Otherwise, the one closest to one of the end points is chosen.
- Parameters:
aP1
- a point on the first geodesic.aP2
- another point on the first geodesic. Should not coincide with aP1.aP3
- a point on the second geodesic.aP4
- another point on the second geodesic. Should not coincide with aP3.aLLResultSFCT
- the intersection point as side effect.- Throws:
IllegalArgumentException
- if no intersection point can be found or chosen.
-
intersectionGeodesicGeodesic
public static void intersectionGeodesicGeodesic(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT) throws IllegalArgumentException Calculates the intersection point of two great circle lines (geodesics) defined by the given points. Seeintersection2DLineSegments(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
for calculating the intersection of line segments.Since great circle planes that do no coincide always have two intersection points, the most appropriate is chosen. If one of the two possibilities is on one of the line segments that one is chosen. Otherwise, the one closest to one of the end points is chosen.
- Parameters:
aP1
- a point on the first geodesic.aP2
- another point on the first geodesic. Should not coincide with aP1.aP3
- a point on the second geodesic.aP4
- another point on the second geodesic. Should not coincide with aP3.aLLResultSFCT
- the intersection point as side effect.- Throws:
IllegalArgumentException
- if no intersection point can be found or chosen.- Since:
- 2021.0
-
intersection2DLSSFCT
@Deprecated public static void intersection2DLSSFCT(double aLon1, double aLat1, double aLon2, double aLat2, double aLon3, double aLat3, double aLon4, double aLat4, ILcd2DEditablePoint aLLP) throws IllegalArgumentException Deprecated.the name of this method contradicts the actual behavior, useintersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
Calculates the intersection point of two great circle lines defined by the pairs(aLon1,aLat1)-(aLon2,aLat2)
and(aLon3,aLat3)-(aLon4,aLat4)
. The intersection does not necessarily lie on one of the two line segments. Since great circle planes that do no coincide always have two intersection points, the most appropriate is chosen. If one of the two possibilities is on one of the line segments that one is chosen. Otherwise, the one closest to one of the end points is chosen.- Parameters:
aLon1
- longitude of start point of first line segment (in degrees).aLat1
- latitude of end point of first line segment (in degrees).aLon2
- longitude of start point of first line segment (in degrees).aLat2
- latitude of end point of first line segment (in degrees).aLon3
- longitude of start point of second line segment (in degrees).aLat3
- latitude of end point of second line segment (in degrees).aLon4
- longitude of start point of second line segment (in degrees).aLat4
- latitude of end point of second line segment (in degrees).aLLP
- the intersection point as side effect.- Throws:
IllegalArgumentException
- if no intersection point can be found or chosen.
-
intersection2DLSSFCT
@Deprecated public static int intersection2DLSSFCT(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aP3, ILcdPoint aP4, ILcd2DEditablePoint aLLResultSFCT1, ILcd2DEditablePoint aLLResultSFCT2) Deprecated.the name of this method contradicts the actual behavior, useintersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)
Calculates the intersection point of two great circle lines defined by the pairs throughaP1-aP2
andaP3-aP4
that intersect each other. The pointsaP1
andaP2
should not coincide nor should the pointsaP3
andaP4
. The intersection does not necessarily lie on one of the two line segments. However, great circle planes that do no coincide always have two intersection points.- Parameters:
aP1
- start point of the first line segment.aP2
- end point of the first line segment.aP3
- start point of the second line segment.aP4
- end point of the second line segment.aLLResultSFCT1
- the intersection point as side effect.aLLResultSFCT2
- the intersection point as side effect.- Returns:
- the number of intersection points. If the great circle planes do not coincide this will be 2. If they do coincide the return code will be -1.
-
intersects2DSR
public static boolean intersects2DSR(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles intersect.- Parameters:
aLon1
- longitude of lower left corner point of the first rectangle in degrees.aLat1
- latitude of lower left corner point of the first rectangle in degrees.aWidth1
- width of the first rectangle (>=0) in degrees.aHeight1
- height of the first rectangle (>=0) in degrees.aLon2
- longitude of lower left corner point of the second rectangle in degrees.aLat2
- latitude of lower left corner point of the second rectangle in degrees.aWidth2
- width of the second rectangle (>=0) in degrees.aHeight2
- height of the second rectangle (>=0) in degrees.- Returns:
- true if the two rectangles intersect each other, false otherwise.
-
overlaps2DSR
public static boolean overlaps2DSR(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles overlap.- Parameters:
aLon1
- longitude of lower left corner point in degrees.aLat1
- latitude of lower left corner point in degrees.aWidth1
- width of the rectangle (>=0) in degrees.aHeight1
- height of the rectangle (>=0) in degrees.aLon2
- longitude of lower left corner point in degrees.aLat2
- latitude of lower left corner point in degrees.aWidth2
- width of the rectangle (>=0) in degrees.aHeight2
- height of the rectangle (>=0) in degrees.- Returns:
- true if the two rectangles overlap each other, false otherwise.
-
overlaps2DSRLowLeft
public static boolean overlaps2DSRLowLeft(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether two 2D rectangles overlap. It includes the lower and left border for overlap, but excludes the upper and right border.- Parameters:
aLon1
- longitude of lower left corner point in degrees.aLat1
- latitude of lower left corner point in degrees.aWidth1
- width of the rectangle (>=0) in degrees.aHeight1
- height of the rectangle (>=0) in degrees.aLon2
- longitude of lower left corner point in degrees.aLat2
- latitude of lower left corner point in degrees.aWidth2
- width of the rectangle (>=0) in degrees.aHeight2
- height of the rectangle (>=0) in degrees.- Returns:
- true if the two rectangles overlap each other, false otherwise.
-
contains2D
Checks whether the pointaPoint
lies on the geodesic line segmentaP1-aP2
.- Parameters:
aP1
- start point of line segment.aP2
- end point of line segment.aPoint
- point to be checked.- Returns:
- true if the point lies on the line segment, false otherwise.
-
circleContains2D
public static boolean circleContains2D(ILcdPoint aCenter, double aCircleRadius, double aSphereRadius, ILcdPoint aPoint) Checks whether the pointaPoint
lies within the circle(aCenter,aCircleRadius)
on the sphere with radiusaSphereRadius
.- Parameters:
aCenter
- center point of the circle.aCircleRadius
- radius of the circle in meters.aSphereRadius
- radius of the sphere in meters.aPoint
- point to be tested.- Returns:
- true if the point lies inside the circle, false otherwise.
-
arcContains2D
public static boolean arcContains2D(ILcdPoint aCenter, double aMajorAxe, double aMinorAxe, double aRotAngle, double aStartAngle, double aArcAngle, double aSphereRadius, ILcdPoint aLLPoint) Checks whether the pointaLLPoint
lies on the elliptical arc segment.- Parameters:
aCenter
- center point of the elliptical arc.aMajorAxe
- major axis of the elliptical arc (meters).aMinorAxe
- minor axis of the elliptical arc (meters).aRotAngle
- rotation angle of the axis in degrees.aStartAngle
- start angle of the arc segment in degrees, positive counter clockwise, starting from 3O'clock.aArcAngle
- length of arc segment in arc degrees.aSphereRadius
- radius of the sphere in meters.aLLPoint
- point to be tested.- Returns:
- true if the point lies on the elliptical arc segment, false otherwise.
-
arcContains2D
Checks whether the pointaLLPoint
lies on the elliptical arc segment.- Parameters:
aArc
- elliptical arc.aSphereRadius
- radius of the sphere in meters.aLLPoint
- point to be tested.- Returns:
- true if the point lies on the elliptical arc segment, false otherwise.
-
polygonContains2D
Checks if a point lies inside a polygon. We define theILcdPoint
aPoint
to be inside if:-
aPoint
interacts with the polygon bounds -
aPoint
has an odd number of polygon edge intersections within a distance of 180 degrees in northern direction (azimuth zero degrees) if this fails we also try in southern direction
- Parameters:
aPolygon
- polygon w.r.t. which the test is performed.aPoint
- the point to be tested.- Returns:
- true if the point lies inside the polygon, false otherwise.
-
-
polygonContains2D
Checks if a point lies inside a polygon. We define the point with coordinatesaLonP
,aLatP
to be inside if:- the point interacts with the polygon bounds
- the point has an odd number of polygon edge intersections within a distance of 180 degrees in northern direction (azimuth zero degrees) if this fails we also try in southern direction
- Parameters:
aPolygon
- polygon w.r.t. which the test is performed.aLonP
- longitude of the point to be tested in degrees.aLatP
- latitude of the point to be tested in degrees.- Returns:
- true if the point lies inside the polygon, false otherwise.
-
calculateBounds
public static void calculateBounds(ILcdPointList aPointList, boolean aPolygon, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException Calculates the bounding box containing the polyline/polygon formed by the point list assuming great circle line segments.- Parameters:
aPointList
- polygon or polyline.aPolygon
- if true the point list is treated as a polygon, otherwise as a polyline.aBoundsSFCT
- the bounding box for the polyline/polygon as side effect.- Throws:
TLcdNoBoundsException
- if the polyline/polygon doesn't have a bounding box.
-
contains2DLS
Checks if the line segmentaP1-aP2
contains the line segmentaP3-aP4
.- Parameters:
aP1
- start point of the first line segment.aP2
- end point of the first line segment.aP3
- start point of the second line segment.aP4
- end point of the second line segment.- Returns:
- true if both end points of the second line segment lie on the first line segment, false otherwise.
-
contains2DSR
public static boolean contains2DSR(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Checks whether a 2D rectangle contains another rectangle.- Parameters:
aLon1
- longitude of lower left corner point in degrees.aLat1
- latitude of lower left corner point in degrees.aWidth1
- width of the rectangle (>=0) in degrees.aHeight1
- height of the rectangle (>=0) in degrees.aLon2
- longitude of lower left corner point in degrees.aLat2
- latitude of lower left corner point in degrees.aWidth2
- width of the rectangle (>=0) in degrees.aHeight2
- height of the rectangle (>=0) in degrees.- Returns:
- true if the second rectangle lies within the first, false otherwise.
-
intersects2DCircleLineSegment
public static boolean intersects2DCircleLineSegment(ILcdPoint aCenter, double aRadius, ILcdPoint aP1, ILcdPoint aP2) Checks whether a circle and a line segment intersect each other.- Parameters:
aCenter
- lon-lat coordinate of center point.aRadius
- radius of circle expressed in arc degrees.aP1
- end point of line segment.aP2
- end point of line segment.- Returns:
- true if the circle and the line segment intersect, false otherwise.
-
intersects2DLineSegmentCircularArc
public static boolean intersects2DLineSegmentCircularArc(ILcdPoint aP1, ILcdPoint aP2, ILcdPoint aCenter, double aRadius, double aStartAngle, double aArcAngle) Checks whether a line segment and a circular arc segment intersect each other. The radius of the circular arc has to be provided in degrees.- Parameters:
aP1
- end point of the line segment.aP2
- end point of the line segment.aCenter
- center of the circular arc segment.aRadius
- radius of the circular arc segment in degrees.aStartAngle
- start angle of arc segment expressed in degrees, positive counter clock wise starting from 3O'Clock.aArcAngle
- length of arc angle in degrees.- Returns:
- true if the line segment and the circular arc segment intersect, false otherwise.
-
intersects2DCircularArcCircularArc
public static boolean intersects2DCircularArcCircularArc(ILcdPoint aCenter1, double aRadius1, double aStartAngle1, double aArcAngle1, ILcdPoint aCenter2, double aRadius2, double aStartAngle2, double aArcAngle2) Checks whether two circular arcs intersect each other. The radii of the arcs have to be given in arc degrees!- Parameters:
aCenter1
- center point of first circular arc.aRadius1
- radius of first circular arc in degrees.aStartAngle1
- start angle of arc segment expressed in degrees, positive counter clock wise starting from 3 O'Clock.aArcAngle1
- length of arc in degrees.aCenter2
- center point of second circular arc.aRadius2
- radius of second circular arc in degrees.aStartAngle2
- start angle of arc segment expressed in degrees, positive counter clock wise starting from 3 O'Clock.aArcAngle2
- length of arc in degrees.- Returns:
- true if the circular arc segments intersect, false otherwise.
-
bufferContour2DOfSegmentSFCT
public static void bufferContour2DOfSegmentSFCT(ILcdPoint aStartPoint, ILcdPoint aEndPoint, double aWidth, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the rectangle defined byaStartPoint
,aEndPoint
, andaWidth
, as an array of 4ILcd2DEditablePoint
objects. The ordering of the points of the contour is clockwise starting from the first point of the rectangle.Because there are only 4 points used to define the contour, the contour representation becomes less accurate when the start and end point are further removed from each other: the connected contour lines no longer lie at the given distance from the axis at each intermediate point. For a more accurate calculation of a buffer contour that uses additional contour points if necessary, please refer to
TLcdEllipsoidUtil#computeBufferContour2D
.- Parameters:
aStartPoint
- start point of buffer segment.aEndPoint
- end point of buffer segment.aWidth
- distance from the line segment to the contour in arc degrees.a2DEditablePointArraySFCT
- an initialized array of 4ILcd2DEditablePoint
objects, which will represent the contour polygon.
-
contour2DOfBoundsSFCT
public static void contour2DOfBoundsSFCT(ILcdBounds aBounds, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the givenILcdBounds
, as an array ofILcd2DEditablePoint
objects.- Parameters:
aBounds
- bounds object.a2DEditablePointArraySFCT
- an initialized array of 4ILcd2DEditablePoint
which will contain the contour.
-
bufferContour2DOf2DPolyline
public static void bufferContour2DOf2DPolyline(ILcdPointList aPointList, double aWidth, ILcd2DEditablePoint[] a2DEditablePointArraySFCT) Calculates the contour of the buffer/corridor along a givenILcdPointList
at a given width. No two successive points should coincide! The ordering of the points of the contour is clockwise starting from the first point of the rectangle.This implementation has the following limitations:
- contours with holes (i.e., caused by axis intersections) cannot
be represented, since the contour is modeled as an
ILcd2DEditablePoint
array, - the corners of the contour at the axis points are sharp instead of rounded, which make it less suitable for buffers that have sharp angles between its consecutive axis segments; it has also has as consequence that the distance between the contour and the axis exceeds the given buffer distance in the corners,
- the calculated contour is only an estimate, because it uses a reduced number of contour points; when the start and end point of a segment are further removed from each other, the connected contour lines no longer lie at the given distance from the axis at each intermediate point.
TLcdEllipsoidUtil#computeBufferContour2D
.- Parameters:
aPointList
- the axis of the buffer.aWidth
- distance from the axis to the contour in arc degrees.a2DEditablePointArraySFCT
- an initialized array ofaPointList.getPointCount() * 2
ILcd2DEditablePoint
objects, which will represent the contour polygon.
- contours with holes (i.e., caused by axis intersections) cannot
be represented, since the contour is modeled as an
-
greatCircleDistance3D
Calculates the distance to go from point p1 to point p2. UnlikeTLcdSphereUtil#greatCircleDistance
, which ignores the height of the points, the distance calculations of this method take the heights of the given points into account.- Parameters:
aPoint1
- the start (geodetic) pointaPoint2
- the end (geodetic) pointaRadius
- the radius of the sphere on which to perform the distance calculation- Returns:
- the 3D distance of the line segment formed by aPoint1 and aPoint2
- Since:
- 2022.1
-
intersectionGeodesicGeodesic(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.shape.shape2D.ILcd2DEditablePoint)