Class Polygon (version 0.16)Description: A polygon class A polygon consists of an outer hull and zero to many holes. Each contour consists of several points. The point list is normalized such that the leftmost, lowest point is the first one. The orientation is normalized such that the orientation of the hull contour is clockwise, while the orientation of the holes is counterclockwise. It is in no way checked that the contours are not over- lapping. This must be ensured by the user of the object when filling the contours.
Method Overview
[const] bool !=( Polygon p )Description: Inequality test
[const] bool <( Polygon p )Description: Less operator This operator is provided to establish some, not necessarily a certain sorting order
[const] bool ==( Polygon p )Description: Equality test
[const] long long areaDescription: The area of the polygon The area is correct only if the polygon is not self-overlapping and the polygon is oriented clockwise.
[const] const ref Box bboxDescription: Return the bounding box of the polygon
destroyDescription: Explicitly destroy the object Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.
[const] bool destroyedDescription: Tell, if the object was destroyed This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.
yield Edge each_edgeDescription: Iterate over the edges that make up the polygon
[const] yield Point each_point_hole( unsigned int n )Description: Iterate over the points that make up the nth hole The hole number must be less than the number of holes (see holes)
[const] yield Point each_point_hullDescription: Iterate over the points that make up the hull
[static] Polygon from_dpoly( DPolygon double_poly )Description: Construct an integer-coordinate polygon from a floating-point coordinate one This method has been added in version 0.15.
[const] unsigned int holesDescription: Get the number of holes
hull=( Point p[ ] )Description: Set the points of the hull of polygon
insert_hole( Point p[ ] )Description: Insert a hole with the given points
[const] bool inside( Point p )Description: Test, if the given point is inside the polygon If the given point is inside the polygon, true is returned. This tests works well only if the polygon is not self-overlapping and oriented clockwise.
ref Polygon move( Point p )Description: Moves the polygon. Moves the polygon by the given offset and returns the moved polygon. The polygon is overwritten.
[const] Polygon moved( Point p )Description: Returns the moved polygon Moves the polygon by the given offset and returns the moved polygon. The polygon is not modified.
[static] Polygon new( Box box )
|
box: | The box to convert to a polygon |
Description: Constructor given the points of the polygon hull
pts: | The points forming the polygon hull |
Description: Default constructor: creates an empty (invalid) polygon
Description: Get the number of points of the given hole
The argument gives the index of the hole of which the number of points are requested. The index must be less than the number of holes (see holes).
Description: Get the number of points of the hull
Description: Convert to a string
Description: Transform the polygon
Transforms the polygon with the given transformation. Does not modify the polygon but returns the transformed polygon.
t: | The transformation to apply. |
returns: | The transformed polygon. |
Description: Transform the polygon with a complex transformation
Transforms the polygon with the given complex transformation. Does not modify the polygon but returns the transformed polygon.
t: | The transformation to apply. |
returns: | The transformed polygon. |