Class SimplePolygon (version 0.16)

Description: A simple polygon class

A simple polygon consists of an outer hull only. The hull 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.

It is in no way checked that the contours are not overlapping This must be ensured by the user of the object when filling the contours.

Class overview

Index

Method Overview

[static] SimplePolygon newDefault constructor: creates an empty (invalid) polygon
[static] SimplePolygon new( Point pts[ ] )Constructor given the points of the simple polygon
[static] SimplePolygon new( Box box )Constructor converting a box to a polygon
[const] bool ==( SimplePolygon )Equality test
[const] bool !=( SimplePolygon )Inequality test
points=( Point p[ ] )Set the points of the simple polygon
unsigned int pointsGet the number of points
[const] yield Point each_pointIterate over the points that make up the simple polygon
yield Edge each_edgeIterate over the edges that make up the simple polygon
[const] bool inside( Point p )Test, if the given point is inside the polygon
ref SimplePolygon move( Point p )Moves the simple polygon.
[const] SimplePolygon moved( Point p )Returns the moved simple polygon
[const] SimplePolygon transformed( Trans t )Transform the simple polygon.
[const] DSimplePolygon transformed_cplx( CplxTrans t )Transform the simple polygon.
[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 simple polygon
[static] SimplePolygon from_dpoly( DSimplePolygon 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 !=( SimplePolygon )

Description: Inequality test

[const] bool ==( SimplePolygon )

Description: Equality test

[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 simple 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 simple polygon

[const] yield Point each_point

Description: Iterate over the points that make up the simple polygon

[static] SimplePolygon from_dpoly( DSimplePolygon double_poly )

Description: Construct an integer-coordinate polygon from a floating-point coordinate one

This method has been added in version 0.15.

[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 SimplePolygon move( Point p )

Description: Moves the simple polygon.

Moves the simple polygon by the given offset and returns the moved simple polygon. The polygon is overwritten.

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

[const] SimplePolygon moved( Point p )

Description: Returns the moved simple polygon

Moves the simple polygon by the given offset and returns the moved simple polygon. The polygon is not modified.

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

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

Description: Constructor given the points of the simple polygon

pts:The points forming the simple polygon

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

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

[static] SimplePolygon new

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

unsigned int points

Description: Get the number of points

points=( Point p[ ] )

Description: Set the points of the simple polygon

p:An array of points to assign to the simple polygon

[const] string to_s

Description: Convert to a string

[const] SimplePolygon transformed( Trans t )

Description: Transform the simple polygon.

Transforms the simple polygon with the given transformation. Does not modify the simple polygon but returns the transformed polygon.

t:The transformation to apply.
returns:The transformed simple polygon.

[const] DSimplePolygon transformed_cplx( CplxTrans t )

Description: Transform the simple polygon.

Transforms the simple polygon with the given complex transformation. Does not modify the simple polygon but returns the transformed polygon.

t:The transformation to apply.
returns:The transformed simple polygon.