Class DSimplePolygon (version 0.16)

Description: A simple polygon class

A simple polygon consists of an outer hull only. The 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 over- lapping. This must be ensured by the user of the object when filling the contours.

Class overview

Index

Method Overview

[static] DSimplePolygon newDefault constructor: creates an empty (invalid) polygon
[static] DSimplePolygon new( DPoint pts[ ] )Constructor given the points of the simple polygon
[static] DSimplePolygon new( DBox box )Constructor converting a box to a polygon
[const] bool ==( DSimplePolygon )Equality test
[const] bool !=( DSimplePolygon )Inequality test
points=( DPoint p[ ] )Set the points of the simple polygon
unsigned int pointsGet the number of points
[const] yield DPoint each_pointIterate over the points that make up the simple polygon
yield DEdge each_edgeIterate over the edges that make up the simple polygon
[const] bool inside( DPoint p )Test, if the given point is inside the polygon
ref DSimplePolygon move( DPoint p )Moves the simple polygon.
[const] DSimplePolygon moved( DPoint p )Returns the moved simple polygon
[const] DSimplePolygon transformed( DTrans t )Transform the simple polygon.
[const] DSimplePolygon transformed_cplx( DCplxTrans t )Transform the simple polygon.
[const] string to_sConvert to a string
[const] double areaThe area of the polygon
[const] const ref DBox bboxReturn the bounding box of the simple polygon
[static] DSimplePolygon from_ipoly( SimplePolygon int_poly )Construct a floating-point coordinate polygon from an integer coordinate one
destroyExplicitly destroy the object
[const] bool destroyedTell, if the object was destroyed

[const] bool !=( DSimplePolygon )

Description: Inequality test

[const] bool ==( DSimplePolygon )

Description: Equality test

[const] double 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 DBox 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 DEdge each_edge

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

[const] yield DPoint each_point

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

[static] DSimplePolygon from_ipoly( SimplePolygon int_poly )

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

This method has been added in version 0.15.

[const] bool inside( DPoint 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 DSimplePolygon move( DPoint 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] DSimplePolygon moved( DPoint 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] DSimplePolygon new( DPoint pts[ ] )
synonym: [static] DSimplePolygon new_p( DPoint pts[ ] )

Description: Constructor given the points of the simple polygon

pts:The points forming the simple polygon

[static] DSimplePolygon new( DBox box )
synonym: [static] DSimplePolygon new_b( DBox box )

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

[static] DSimplePolygon new

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

unsigned int points

Description: Get the number of points

points=( DPoint 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] DSimplePolygon transformed( DTrans 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( DCplxTrans 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.