geirs2Panic  Richard J. Mathar
Fits header keyword batch editor
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Public Attributes | List of all members
Square2D Class Reference

A square represented by the four vertices of the corners. More...

#include <Square2D.h>

Collaboration diagram for Square2D:
Collaboration graph

Public Member Functions

 Square2D (const Point2D &pt1, const Point2D &pt2)
 Create a planar square given the first two adjacent vertices. More...
 
 Square2D (const Point2D &pt1, const Point2D &pt2, const Point2D &pt3, const Point2D &pt4)
 Create a planar square given all four vertices. More...
 
 Square2D ()
 
 operator Bbox2D () const
 Generate the bounding box of this square. More...
 
Line2D edge (int no) const
 
Circle2D circumC () const
 
double area () const
 
Tria2Ddissect () const
 
Square2D apply (const RotTrans2D &rt) const
 Compute the square that is rotated-translated. More...
 
vector< Tria2Dintersect (const Square2D &oth) const
 Compute the common area (intersection) between this and another square. More...
 

Public Attributes

Point2D vert [4]
 The points at the vertices. More...
 
double eLen
 Edge length. More...
 

Detailed Description

A square represented by the four vertices of the corners.

Since
2013-07-03
Author
Richard J. Mathar

Constructor & Destructor Documentation

Square2D::Square2D ( const Point2D pt1,
const Point2D pt2 
)

Create a planar square given the first two adjacent vertices.


The third and fourth vertex are defined by orthogonal extension off the baseline between the first and second vertex.

Parameters
pt1The first vertex.
pt2The second vertex.
Square2D::Square2D ( const Point2D pt1,
const Point2D pt2,
const Point2D pt3,
const Point2D pt4 
)

Create a planar square given all four vertices.


The four vertices are supposed to be given in ccs order. No checking on the length and mutual orthogonality of the edges is done!

Parameters
pt1The first vertex.
pt2The second vertex.
pt3The third vertex.
pt4The fourth vertex.
Square2D::Square2D ( )

Create an empty square with four vertices all at the origin.

Member Function Documentation

Square2D::operator Bbox2D ( ) const

Generate the bounding box of this square.


Returns
The quadrangular bounding box.
Line2D Square2D::edge ( int  no) const

Create a line that connects vertex number 'no' with the next vertex along the edge.

Parameters
noThe edge number in the range 0 to 3.
Returns
The line that connects point no with point no+1. Edge 0 connects vertex 0 to 1. Edge 1 connects vertex 1 to 2. Edge 2 connects vertex 2 to 3. Edge 3 connects vertex 3 to 0.
Circle2D Square2D::circumC ( ) const

Compute the circumcircle.

Returns
The circumcircle. The perimeter of the circle touches all 4 vertices of the Square.
double Square2D::area ( ) const

Compute the area.

Returns
The area. Square of the edge length
Tria2D * Square2D::dissect ( ) const

Dissect the square into two triangles along a diagonal.

Returns
The two triangles. The orientation of the triangles is individually the same as the orientation of the square. We also guarantee that the first two edges of each triangle are orthogonal, which implies that the circumcircles of these are centered at the (common) longest edge.
Square2D Square2D::apply ( const RotTrans2D rt) const

Compute the square that is rotated-translated.


Parameters
[in]rtThe rotation-translation to be applied
Returns
The square defined by individual rotation of all 4 vertices of this.
vector< Tria2D > Square2D::intersect ( const Square2D oth) const

Compute the common area (intersection) between this and another square.


Returns
The vector of mutually non-intersecting pieces of the common area of both polygons. If there is no overlap, the vector that is returned is empty.

Member Data Documentation

Point2D Square2D::vert[4]

The points at the vertices.

double Square2D::eLen

Edge length.