Core 1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Rectangles2 Class Reference

Rectangles in the plane. More...

#include <rectangle.h>

Public Member Functions

 Rectangles2 ()
 Empty.
 
 Rectangles2 (const Vector2 &, const Vector2 &, const double &, const double &)
 Create a rectangle in the xy-plane, centered at the origin. More...
 
 Rectangles2 (const Box2 &)
 Create a rectangle from a box. More...
 
 ~Rectangles2 ()
 Empty.
 
Vector2 Vertex (int) const
 Returns the k-th vertex of the rectangle. More...
 
double Width () const
 Return the width.
 
double Height () const
 Return the height.
 
double R (const Vector2 &) const
 Compute the squared distance between a point and the rectangle. More...
 
Vector2 Normal (const Vector2 &) const
 Compute the vector distance between the box and a point. More...
 
Box2 GetBox () const
 Compute the embedding box.
 
Rectangles ToRectangles () const
 Convert to a rectangle.
 
bool Intersect (const Circle2 &) const
 Check the interscetion with a circle. More...
 
bool Intersect (const Rectangles2 &) const
 Check the intersection with another rectangle. More...
 
void Rotate (const Matrix2 &)
 Rotate the rectangle. More...
 
void Translate (const Vector2 &)
 Translate the rectangle. More...
 
void Scale (const double &)
 Scale the rectangle. More...
 
QPolygonF GetQtPolygon () const
 Convert the rectangle into a Qt polygon.
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a polygon. More...
 

Protected Member Functions

bool Overlap (const Rectangles2 &) const
 Overlapping test for intersection algorithm. More...
 

Protected Attributes

Vector2 x = Vector2::X
 Base horizontal vector.
 
Vector2 c = Vector2::Null
 Center.
 
double b = 1.0
 Width and height.
 

Static Protected Attributes

static double epsilon = 1.0e-8
 Internal \epsilon; constant.
 

Detailed Description

Rectangles in the plane.

Constructor & Destructor Documentation

◆ Rectangles2() [1/2]

Rectangles2::Rectangles2 ( const Vector2 c,
const Vector2 x,
const double &  a,
const double &  b 
)
explicit

Create a rectangle in the xy-plane, centered at the origin.

Parameters
cCenter.
xBase vector.
a,bSize, the rectangle will be twice as large.

◆ Rectangles2() [2/2]

Rectangles2::Rectangles2 ( const Box2 box)
explicit

Create a rectangle from a box.

Parameters
boxThe box.

Member Function Documentation

◆ Draw()

void Rectangles2::Draw ( QGraphicsScene &  scene,
const QPen &  pen = QPen(),
const QBrush &  brush = QBrush() 
) const

Draw a polygon.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ Intersect() [1/2]

bool Rectangles2::Intersect ( const Circle2 circle) const

Check the interscetion with a circle.

Parameters
circleThe circle.

◆ Intersect() [2/2]

bool Rectangles2::Intersect ( const Rectangles2 rectangle) const

Check the intersection with another rectangle.

Parameters
rectangleThe rectangle.

◆ Normal()

Vector2 Rectangles2::Normal ( const Vector2 p) const

Compute the vector distance between the box and a point.

Parameters
pPoint.

◆ Overlap()

bool Rectangles2::Overlap ( const Rectangles2 other) const
protected

Overlapping test for intersection algorithm.

Parameters
otherOther rectangle.

◆ R()

double Rectangles2::R ( const Vector2 p) const

Compute the squared distance between a point and the rectangle.

Parameters
pPoint.

◆ Rotate()

void Rectangles2::Rotate ( const Matrix2 r)

Rotate the rectangle.

Parameters
rRotation matrix.

◆ Scale()

void Rectangles2::Scale ( const double &  s)

Scale the rectangle.

Parameters
sScaling factor.

◆ Translate()

void Rectangles2::Translate ( const Vector2 t)

Translate the rectangle.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 Rectangles2::Vertex ( int  k) const
inline

Returns the k-th vertex of the rectangle.

Parameters
kIndex.
See also
Box2::Vertex(int) const