Package cds.healpix.common.sphgeom
Class Polygon
- java.lang.Object
-
- cds.healpix.common.sphgeom.Polygon
-
public final class Polygon extends java.lang.ObjectClass defining (and storing the vertices of) a polygon on the unit sphere. The original 2D method comes from https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html We adapted it here to the case of the sphere. Remark: in the case of polygons having all their points on a semi-hemisphere, we could have use the classical 2D algorithm on the points projected on a plane by the Gnomonic projections (centered to the center of the MEC). In the gnomonic projection, all great circles arc are strait lines.- Author:
- F.-X. Pineau
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPolygon.ContainsSouthPoleComputerDefines the method used to know if the south pole is in the polygon or in its complement.
-
Constructor Summary
Constructors Constructor Description Polygon(CooXYZ[] polyVertices)Create a new polygon from the given list of vertices, using thePolygon.ContainsSouthPoleComputer.BASICmethod to define its inside and outside.Polygon(CooXYZ[] polyVertices, Polygon.ContainsSouthPoleComputer cspc)Create a new polygon from the given list of vertices, using the given method to define its inside and outside.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(CooXYZ p)Returnstrueif the polygon contain the point p.booleanintersectSegAB(CooXYZ a, CooXYZ b)Returnstrueif an edge of the polygone intersects the line defined by the two given points.intnVertices()Returns the number of vertices the polygon contains.CooXYZvertex(int vertexIndex)Returns the vertex located at the given index in the polygin vertex list.
-
-
-
Constructor Detail
-
Polygon
public Polygon(CooXYZ[] polyVertices)
Create a new polygon from the given list of vertices, using thePolygon.ContainsSouthPoleComputer.BASICmethod to define its inside and outside.- Parameters:
polyVertices- vertices defining the polygon
-
Polygon
public Polygon(CooXYZ[] polyVertices, Polygon.ContainsSouthPoleComputer cspc)
Create a new polygon from the given list of vertices, using the given method to define its inside and outside. WARNING: so far the algorithm compute a minimum encoding cone and methods other than the default,Polygon.ContainsSouthPoleComputer.STD_FXPandPolygon.ContainsSouthPoleComputer.STD_IVOAmay not work properly!!- Parameters:
polyVertices- vertices defining the polygoncspc- method used to defined the inside and the outside of the polygon. So far do not usePolygon.ContainsSouthPoleComputer.STD_FXPandPolygon.ContainsSouthPoleComputer.STD_IVOA.
-
-
Method Detail
-
nVertices
public int nVertices()
Returns the number of vertices the polygon contains.- Returns:
- the number of vertices the polygon contains.
-
vertex
public CooXYZ vertex(int vertexIndex)
Returns the vertex located at the given index in the polygin vertex list.- Parameters:
vertexIndex- index of the vertex we want to access (in [0, nVertices[- Returns:
- the vertex located at the given index in the polygin vertex list.
-
contains
public boolean contains(CooXYZ p)
Returnstrueif the polygon contain the point p.- Parameters:
p- point to test- Returns:
trueif the polygon contain the point p.
-
intersectSegAB
public boolean intersectSegAB(CooXYZ a, CooXYZ b)
Returnstrueif an edge of the polygone intersects the line defined by the two given points.- Parameters:
a- first segment pointb- second segment point- Returns:
trueif an edge of the polygone intersects the line defined by the two given points.
-
-