Public Member Functions

wit::Polygon Class Reference

#include <wit/geometry.h>

List of all members.

Public Member Functions

 Polygon ()
 Polygon (const Polygon &other)
 ~Polygon ()
Polygonoperator= (const Polygon &other)
void addPoint (float x, float y)
void addPoint (const Point &p)
int count () const
Pointpoints () const
Rect boundingBox () const
bool contains (float x, float y) const

Detailed Description

The Polygon class describes an arbitrary two-dimensional polygon.

Definition at line 32 of file geometry.h.


Constructor & Destructor Documentation

wit::Polygon::Polygon (  )

Creates a new empty Polygon object.

Definition at line 179 of file geometry.cpp.

wit::Polygon::Polygon ( const Polygon other )

Creates a new Polygon object that is a copy of other.

Definition at line 187 of file geometry.cpp.

wit::Polygon::~Polygon (  )

Destroys the Polygon object.

Definition at line 195 of file geometry.cpp.


Member Function Documentation

void wit::Polygon::addPoint ( float  x,
float  y 
)

Adds a point to the polygon.

This is an overloaded member function, provided for convenience.

Definition at line 232 of file geometry.cpp.

void wit::Polygon::addPoint ( const Point p )

Adds a point to the polygon.

Definition at line 213 of file geometry.cpp.

Rect wit::Polygon::boundingBox (  ) const

Returns the axis-aligned bounding box of the polygon.

This bounding box is the smallest rectangle parallel to the horizontal and vertical axes contains the entire polygon.

Definition at line 261 of file geometry.cpp.

bool wit::Polygon::contains ( float  x,
float  y 
) const

Returns true if the point (x, y) is contained within the polygon.

This function uses the odd/even method of determining whether or not the point is contained within the polygon. Therefore, a polygon whose boundary contains self-intersections may not yield the expected results.

Definition at line 273 of file geometry.cpp.

int wit::Polygon::count (  ) const

Returns the number of points in the polygon.

Definition at line 240 of file geometry.cpp.

Polygon & wit::Polygon::operator= ( const Polygon other )

Replaces the points of the Polygon object with the points from other.

Definition at line 203 of file geometry.cpp.

Point * wit::Polygon::points (  ) const

Returns a pointer to the array of points in the polygon.

These points may be modified in-place.

Definition at line 250 of file geometry.cpp.


The documentation for this class was generated from the following files: