Polygon_t Class Reference

Class representing a polygon in a 2 dimensional coordinate space. More...

#include <UTGeometry.h>

List of all members.

Public Member Functions

 Polygon_t ()
 Polygon_t (const Point_t *vertices, int num_vertices)
 Polygon_t (const Rect_t &rect)
 Polygon_t (const Polygon_t &polygon)
void AddVertex (const Point_t &vertex)
void InsertVertex (const Point_t &vertex, int index)
void RemoveVertex (int index)
void ReplaceVertex (int index, const Point_t &vertex)
int CountVertices () const
void Clear ()
const Point_tVertexAt (int index) const
const Polygon_toperator= (const Polygon_t &copy)
const Polygon_toperator= (const Rect_t &rect)
void Shift (const Point_t &offset)
bool Contains (const Point_t &point) const
bool Overlapping (const Rect_t &rect) const
Rect_t BoundingBox () const
void GetBoundingBox (out Rect_t *bounding_box) const
void FindClosestPoint (const Point_t &from, out Point_t *closest_point_on_polygon, out int *after_index, bool on_edge_if_inside) const
void RotateAbout (double radians, const Point_t &point)

Detailed Description

Class representing a polygon in a 2 dimensional coordinate space. Although it can be used in other ways, the value space which is typically used is that for a monitor, with increasing x values to the right and increasing y values to the bottom. Floating point numbers are used by the UTgfx and UTgui libraries to represent screen display because for scaling, use of floating point computation until final conversion to an integer coordinate is more efficient than use of integers when scaling. That way the same interface can be used to render to the display, printer, and so on. Floats are accurate to within c_dbl_abs_min_denominator out to about 4,000,000.

Definition at line 501 of file UTGeometry.h.


Constructor & Destructor Documentation

Polygon_t::Polygon_t (  )  [inline]

Constructor for an uninitialized polygon.

Definition at line 1611 of file UTGeometry.h.

Polygon_t::Polygon_t ( const Point_t vertices,
int  num_vertices 
)

Constructor.

Polygon_t::Polygon_t ( const Rect_t rect  ) 

Constructor for a polygon from a rectangle. The vertices are created in the order upper left, upper right, lower right, lower left.

Polygon_t::Polygon_t ( const Polygon_t polygon  ) 

Copy constructor.


Member Function Documentation

void Polygon_t::AddVertex ( const Point_t vertex  )  [inline]

Adds a vertex to the polygon after the last vertex, connected to the first vertex to complete the polygon.

Definition at line 1618 of file UTGeometry.h.

void Polygon_t::InsertVertex ( const Point_t vertex,
int  index 
) [inline]

Adds a vertex to the polygon at the specified index, connected to the vertex at index-1 and the vertex previously at index, with the vertex previously at index then at index+1.

Definition at line 1625 of file UTGeometry.h.

void Polygon_t::RemoveVertex ( int  index  )  [inline]

Removes the vertex at the specified index.

Definition at line 1639 of file UTGeometry.h.

void Polygon_t::ReplaceVertex ( int  index,
const Point_t vertex 
) [inline]

Replaces the specified vertex with a new point.

Definition at line 1632 of file UTGeometry.h.

int Polygon_t::CountVertices (  )  const [inline]

Returns the number of vertices.

Definition at line 1646 of file UTGeometry.h.

void Polygon_t::Clear (  )  [inline]

Removes all vertices.

Definition at line 1653 of file UTGeometry.h.

const Point_t & Polygon_t::VertexAt ( int  index  )  const [inline]

Returns the vertex at the specified index.

Definition at line 1660 of file UTGeometry.h.

const Polygon_t& Polygon_t::operator= ( const Polygon_t copy  ) 

Assignment operator.

const Polygon_t& Polygon_t::operator= ( const Rect_t rect  ) 

Assignment operator.

void Polygon_t::Shift ( const Point_t offset  ) 

Adds the x and y values of the specified point to all vertices. Unlike the other geometry structs and classes, Polygon_t does not have operators +, -, +=, or -= a Point_t because in this case it would be ambiguous whether the point should be an offset or a new vertex added to or existing vertex removed from the polygon.

bool Polygon_t::Contains ( const Point_t point  )  const

Returns true if this polygon (not its bounding box) contains the specified point.

bool Polygon_t::Overlapping ( const Rect_t rect  )  const

Returns true if this polygon (not its bounding box) at least partially overlaps the rectangle.

Rect_t Polygon_t::BoundingBox (  )  const [inline]

Returns the bounding box which would enclose the entire polygon.

Definition at line 1668 of file UTGeometry.h.

void Polygon_t::GetBoundingBox ( out Rect_t bounding_box  )  const

Returns the bounding box which would enclose the entire polygon.

void Polygon_t::FindClosestPoint ( const Point_t from,
out Point_t closest_point_on_polygon,
out int *  after_index,
bool  on_edge_if_inside 
) const

Finds the closest point on the polygon, returning the closest point through the closest_point_on_polygon parameter, and the index of the starting vertex of the line segment on which the closest point resides. In other words, if *after_index is set to 0, the point is closest to the line segment from vertex 0 to vertex 1. If on_edge_if_inside is false, the point may be within the body of the polygon. In that case, *after_index will still be set to the starting vertex of the line segment which is closest to the point. Either pointer can be NULL if the value is not needed.

void Polygon_t::RotateAbout ( double  radians,
const Point_t point 
)

Rotates the polygon clockwise about the specified point by the specified number of radians.


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

Generated on Tue Dec 14 22:35:07 2010 for UT library by  doxygen 1.6.1