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.

Class overview

Index

Method Overview

[static] Polygon newDefault constructor: creates an empty (invalid) polygon
[static] Polygon new( Point pts[ ] )Constructor given the points of the polygon hull
[static] Polygon new( Box box )Constructor converting a box to a polygon
[const] bool <( Polygon p )Less operator
[const] bool ==( Polygon p )Equality test
[const] bool !=( Polygon p )Inequality test
hull=( Point p[ ] )Set the points of the hull of polygon
unsigned int points_hullGet the number of points of the hull
unsigned int points_hole( unsigned int n )Get the number of points of the given hole
insert_hole( Point p[ ] )Insert a hole with the given points
[const] yield Point each_point_hullIterate over the points that make up the hull
[const] yield Point each_point_hole( unsigned int n )Iterate over the points that make up the nth hole
[const] unsigned int holesGet the number of holes
yield Edge each_edgeIterate over the edges that make up the polygon
[const] bool inside( Point p )Test, if the given point is inside the polygon
ref Polygon move( Point p )Moves the polygon.
[const] Polygon moved( Point p )Returns the moved polygon
[const] Polygon transformed( Trans t )Transform the polygon
[const] DPolygon transformed_cplx( CplxTrans t )Transform the polygon with a complex transformation
[const] string to_sConvert to a string
[const] long long areaThe area of the polygon
[const] const ref Box bboxReturn the bounding box of the polygon
[static] Polygon from_dpoly( DPolygon double_poly )Construct an integer-coordinate polygon from a floating-point coordinate one
destroyExplicitly destroy the object
[const] bool destroyedTell, if the object was destroyed

[const] bool !=( Polygon p )

Description: Inequality test

p:The object to compare against

[const] bool <( Polygon p )

Description: Less operator

This operator is provided to establish some, not necessarily a certain sorting order

p:The object to compare against

[const] bool ==( Polygon p )

Description: Equality test

p:The object to compare against

[const] long long area

Description: 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 bbox

Description: Return the bounding box of the polygon

destroy

Description: 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 destroyed

Description: 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_edge

Description: 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_hull

Description: 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 holes

Description: Get the number of holes

hull=( Point p[ ] )

Description: Set the points of the hull of polygon

p:An array of points to assign to the polygon's hull

insert_hole( Point p[ ] )

Description: Insert a hole with the given points

p:An array of points to insert as a new hole

[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.

p:The distance to move the polygon.
returns:The moved polygon.

[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.

p:The distance to move the polygon.
returns:The moved polygon.

[static] Polygon new( Box box )
synonym: [static] Polygon new_b( Box box )

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

[static] Polygon new( Point pts[ ] )
synonym: [static] Polygon new_p( Point pts[ ] )

Description: Constructor given the points of the polygon hull

pts:The points forming the polygon hull

[static] Polygon new

Description: Default constructor: creates an empty (invalid) polygon

unsigned int points_hole( unsigned int n )

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).

unsigned int points_hull

Description: Get the number of points of the hull

[const] string to_s

Description: Convert to a string

[const] Polygon transformed( Trans t )

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.

[const] DPolygon transformed_cplx( CplxTrans t )

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.