ManglePolygon¶
-
class
pydl.pydlutils.mangle.
ManglePolygon
(*args, **kwargs)[source]¶ Bases:
object
Simple object to represent a polygon.
A polygon may be instantiated with a row (
FITS_record
) from aFITS_polygon
object, anotherManglePolygon
object (copy constructor), keyword arguments, or with no arguments at all, in which case it represents the whole sky.Attributes: Attributes Summary
ncaps
Number of caps in the polygon. str
Solid angle of this polygon (steradians). x
The orientation of each cap in the polygon. Methods Summary
add_caps
(x, cm)Create a new polygon that contains additional caps. cmminf
()The index of the smallest cap in the polygon, accounting for negative caps and use_caps
.copy
()Return an exact copy of the polygon. garea
()Compute the area of a polygon. gzeroar
()If at least one cap has zero area, then the whole polygon has zero area. polyn
(other, n[, complement])Intersection of a polygon with the n
th cap of another polygon.Attributes Documentation
-
ncaps
¶ Number of caps in the polygon.
-
str
¶ Solid angle of this polygon (steradians).
-
x
¶ The orientation of each cap in the polygon. The direction is specified by a unit 3-vector.
Methods Documentation
-
add_caps
(x, cm)[source]¶ Create a new polygon that contains additional caps. The caps are appended to the existing polygon’s caps.
Parameters: Returns: - :class:`ManglePolygon`
A new polygon object.
-
cmminf
()[source]¶ The index of the smallest cap in the polygon, accounting for negative caps and
use_caps
.Returns: - :class:`int`
Integer index of the smallest cap.
-
copy
()[source]¶ Return an exact copy of the polygon.
Returns: - :class:`ManglePolygon`
A new polygon object.
-
garea
()[source]¶ Compute the area of a polygon.
See [1] for the detailed area formula, which is summarized here:
- An empty polygon with no caps is defined to be the whole sky.
- A polygon with one cap has area
2*pi*self.cm
. - A polygon with at least one cap with an area less than \(2\pi\) has an area less than \(2\pi\).
- If every cap has an area greater than \(2\pi\), split the polygon into two smaller polygons and sum the two areas.
Returns: - :class:`float`
The area of the polygon.
References
[1] Hamilton, A. J. S.; Tegmark, Max, 2004 MNRAS 349, 115.
-
gzeroar
()[source]¶ If at least one cap has zero area, then the whole polygon has zero area.
Returns: - :class:`bool`
True
if the area is zero.
-
polyn
(other, n, complement=False)[source]¶ Intersection of a polygon with the
n
th cap of another polygon.Parameters: - other :
ManglePolygon
Polygon containing a cap to intersect the first polygon with.
- n :
int
Index of the cap in
other
.- complement :
bool
, optional If
True
, set the sign of the cm value ofother
to be the complement of the original value.
Returns: - :class:`~pydl.pydlutils.mangle.ManglePolygon`
A polygon containing the intersected caps.
- other :
-