Package uk.ac.starlink.ttools.func
Class Sky
java.lang.Object
uk.ac.starlink.ttools.func.Sky
Functions useful for working with shapes on a sphere.
All angles are expressed in degrees.
- Since:
- 13 Feb 2019
- Author:
- Mark Taylor
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
inSkyEllipse
(double lon0, double lat0, double lonCenter, double latCenter, double rA, double rB, double posAng) Tests whether a given sky position is inside a given ellipse.static boolean
inSkyPolygon
(double lon0, double lat0, double... lonLats) Tests whether a given sky position is inside the polygon defined by a given set of vertices.static double
midLat
(double lat1, double lat2) Determines the latitude midway between two given latitudes.static double
midLon
(double lon1, double lon2) Determines the longitude mid-way between two given longitudes.static double
skyDistance
(double lon1, double lat1, double lon2, double lat2) Calculates the separation (distance around a great circle) of two points on the sky in degrees.
-
Method Details
-
skyDistance
public static double skyDistance(double lon1, double lat1, double lon2, double lat2) Calculates the separation (distance around a great circle) of two points on the sky in degrees.This function is identical to
skyDistanceDegrees
in classCoordsDegrees
.- Parameters:
lon1
- point 1 longitude in degreeslat1
- point 1 latitude in degreeslon2
- point 2 longitude in degreeslat2
- point 2 latitude in degrees- Returns:
- angular distance between point 1 and point 2 in degrees
-
midLon
public static double midLon(double lon1, double lon2) Determines the longitude mid-way between two given longitudes. In most cases this is just the mean of the two values, but this function copes correctly with the case where the given values straddle the lon=0 line.- Parameters:
lon1
- first longitude in degreeslon2
- second longitude in degrees- Returns:
- longitude midway between the given values
- Examples:
midLon(204.0, 203.5) = 203.75
,midLon(2, 359) = 0.5
-
midLat
public static double midLat(double lat1, double lat2) Determines the latitude midway between two given latitudes. This simply returns the mean of the two values, but is supplied for convenience to use alongside themidLon
function.- Parameters:
lat1
- first latitude in degreeslat2
- second latitude in degrees- Returns:
- latitude midway between the given values
- Examples:
midLat(23.5, 24.0) = 23.75
-
inSkyEllipse
public static boolean inSkyEllipse(double lon0, double lat0, double lonCenter, double latCenter, double rA, double rB, double posAng) Tests whether a given sky position is inside a given ellipse.- Parameters:
lon0
- test point longitude in degreeslat0
- test point latitude in degreeslonCenter
- ellipse center longitude in degreeslatCenter
- ellipse center latitude in degreesrA
- ellipse first principal radius in degreesrB
- ellipse second principal radius in degreesposAng
- position angle in degrees from the North pole to the primary axis of the ellipse in the direction of increasing longitude- Returns:
- true iff test point is inside, or on the border of, the ellipse
-
inSkyPolygon
public static boolean inSkyPolygon(double lon0, double lat0, double... lonLats) Tests whether a given sky position is inside the polygon defined by a given set of vertices. The bounding lines of the polygon are the minor arcs of great circles between adjacent vertices, with an extra line assumed between the first and last supplied vertex. The interior of the polygon is defined to be the smaller of the two regions separated by the boundary. The vertices are specified as a sequence of loni, lati pairs.The implementation of this point-in-polygon function is mostly correct, but may not be bulletproof. It ought to work for relatively small regions anywhere on the sky, but for instance it may get the sense wrong for regions that extend to cover both poles.
- Parameters:
lon0
- test point latitude in degreeslat0
- test point longitude in degreeslonLats
- 2N arguments (lon1
,lat1
,lon2
,lat2
, ...,lonN
,latN
) giving (longitude, latitude) vertices of an N-sided polygon in degrees- Returns:
- true iff test point is inside, or on the border of, the polygon
-