Core 1.0
Public Member Functions | List of all members
Diamond2 Class Reference

A diamond in the plane. More...

#include <diamond2.h>

Inheritance diagram for Diamond2:
Box2

Public Member Functions

 Diamond2 (const Vector2 &, const Vector2 &)
 Creates a diamond given the vectors defining its bounding box. More...
 
 Diamond2 (const Vector2 &, const double &)
 Creates a diamond given its center and axes lengths. More...
 
 Diamond2 (const Vector2 &, const double &, const double &)
 Creates a diamond given its center and axes lengths. More...
 
double Area () const
 Compute the area of the diamond. More...
 
double Perimeter () const
 Compute the perimeter of the diamond. More...
 
Box2 GetBox () const
 Return the bounding box of the shape.
 
double R (const Vector2 &) const
 Compute the squared distance between a point and the diamond. More...
 
Vector2 Vertex (int) const
 Return the i-th vertex. More...
 
Diamond2 Translated (const Vector2 &) const
 Translates the diamond. More...
 
Diamond2 Scaled (const Vector2 &) const
 Scales the diamond. More...
 
void Draw (QGraphicsScene &, const QPen &, const QBrush &) const
 Draw a diamond. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Box2
 Box2 ()
 Empty.
 
 Box2 (const double &)
 Create a square box centered at the origin and of given half side length. More...
 
 Box2 (const double &, const double &)
 Create a box centered at the origin and of given dimensions. More...
 
 Box2 (const Vector2 &)
 Create a box from a single vertex. More...
 
 Box2 (const Vector2 &, const Vector2 &)
 Create a box. More...
 
 Box2 (const Vector2 &, const double &)
 Creates a box. More...
 
 Box2 (const Box &)
 Create a box in the plane given a box. More...
 
 Box2 (const Box2 &, const Box2 &)
 Create a box embedding two boxes. More...
 
 Box2 (const Box2 &, const Matrix2 &)
 Creates an axis aligned bounding box from a box and a transformation matrix. More...
 
 Box2 (const Box2 &, const Frame2 &)
 Creates an axis aligned bounding box from a box and a frame. More...
 
 Box2 (const QVector< Vector2 > &)
 Compute the bounding box of a set of points. More...
 
 Box2 (const QSize &)
 Create a box from a Qt size. More...
 
Vector2operator[] (int)
 Returns either end vertex of the box.
 
Vector2 operator[] (int) const
 Overloaded.
 
Vector2 Size () const
 Compute the size (width and height) of a box.
 
double Width () const
 Compute the width of a box. More...
 
double Height () const
 Compute the height of a box. More...
 
Vector2 Diagonal () const
 Returns the diagonal of the box.
 
double Radius () const
 Returns the radius of the box, i.e. the length of the half diagonal of the box.
 
double Area () const
 Compute the surface area of a box.
 
double Perimeter () const
 Compute the perimeter of the box.
 
Vector2 Center () const
 Returns the center of the box.
 
Vector2 Vertex (int) const
 Returns the k-th vertex of the box. More...
 
Vector2 Vertex (int, int, int, int) const
 Compute the coordinates of a grid aligned point. More...
 
Box2 Sub (int) const
 Computes the sub-box in the n-th quadrant. More...
 
double R (const Vector2 &) const
 Compute the squared distance between the box and a point. More...
 
double Signed (const Vector2 &) const
 Computes the signed distance between the box and a point. More...
 
double R (const Box2 &) const
 Compute the squared Euclidean distance between two boxes. More...
 
void Translate (const Vector2 &)
 Translates a box. More...
 
void Scale (const Vector2 &)
 Scales a box. More...
 
void Scale (const double &)
 Scales a box. More...
 
Box2 Translated (const Vector2 &) const
 Translated box. More...
 
Box2 Scaled (const double &) const
 Scales a box and return the scaled box. More...
 
Box2 Scaled (const Vector2 &) const
 Scales a box and return the scaled box. More...
 
Box2 Scaled (const QSize &) const
 Scales a box according to a Qt size. More...
 
Box2 ScaledTo (const double &) const
 Scale the box so that the largest side should equal the argument value. More...
 
Box2 Rotated (const double &) const
 Compute the box embedding the rotated box. More...
 
Box2 Rotated (const Matrix2 &) const
 Compute the box embedding the rotated box. More...
 
Box2 Centered () const
 Compute the box translated to origin. More...
 
void SetCubic ()
 Creates the tightest embedding cube from an arbitrarilly shaped box. More...
 
void SetInscribedCubic ()
 Creates the biggest cube inscribed in the box. More...
 
Box2 Cube () const
 Return the tightest embedding cube from an arbitrarilly shaped box. More...
 
void Extend (const double &)
 Extend the limits of the box by a given distance. More...
 
void Extend (const Vector2 &)
 Extend the limits of the box given a point. More...
 
Box2 Extended (const double &) const
 Extend the limits of the box by a given distance. More...
 
void SetParallelepipedic (int, int &, int &)
 Inflates a box so that its dimensions should be a fraction of its maximum side length. More...
 
void SetParallelepipedic (const double &, int &, int &)
 Creates a parallelepipedic box whose dimensions are integer multiples of a given input reference size. More...
 
bool Inside (const Vector2 &) const
 Test if a point is inside the box. More...
 
bool Inside (const Vector2 &, const double &) const
 Test if a point lies withing a given range of the box. More...
 
bool Intersect (const Box2 &) const
 Check if the box intersects another box. More...
 
double OverlapArea (const Box2 &) const
 Computes the overlapping area of two boxes. More...
 
Box2 Intersection (const Box2 &) const
 Computes the intersection between two boxes. More...
 
Box ToBox (const double &, const double &) const
 Convert a planar Box2 to a Box. More...
 
int Quadrant (const Vector2 &) const
 Computes quadrant index of a vertex with respect to the box center. More...
 
bool Intersect (const Ray2 &, double &, double &) const
 Computes the intersection between a box and a ray. More...
 
bool Intersect (const Ray2 &) const
 Computes the intersection between a box and a ray. More...
 
bool Intersect (const Line2 &, double &, double &) const
 Computes the intersection between a box and a line. More...
 
bool Intersect (const Segment2 &, double &, double &) const
 Compute the intersection between a box and a segment. More...
 
bool Intersect (const Line2 &) const
 Check the intersection between a box and a line. More...
 
bool Intersect (const Segment2 &) const
 Check the intersection between a box and a segment. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a rectangle. More...
 
Vector2 RandomInside (Random &=Random::R239) const
 Generate a random vector inside the box. More...
 
Vector2 RandomOn (Random &=Random::R239) const
 Generate a random vector on the perimeter of the box. More...
 
QRectF GetQtRect () const
 Create the Qt rectangle.
 
QRect TileRange (const Box2 &) const
 Compute the range of index for tiling the argument box so that it covers the box. More...
 
Box2 Tile (int, int) const
 Return the tiled the box using integer coordinates. More...
 
Box2 Tile (const QRect &) const
 Return the tiled the box using integer coordinates. More...
 
QVector< Vector2Poisson (const double &, int, Random &=Random::R239) const
 Compute a Poisson disc distribution inside a box. More...
 
- Static Protected Member Functions inherited from Box2
static Box2 MinMax (const Vector2 &, const Vector2 &)
 Create a box from any two points. More...
 
- Protected Attributes inherited from Box2
Vector2 b
 Lower and upper vertices of the box.
 
- Static Protected Attributes inherited from Box2
static const double epsilon = 1.0e-5
 Epsilon value used to check intersections and some round off errors.
 
static const Box2 Infinity
 Huge bounding box, which should enclose any other.
 
static const Box2 Null
 Null box, equivalent to. More...
 
static const Box2 Unit
 Unit box, defined as. More...
 

Detailed Description

A diamond in the plane.

Constructor & Destructor Documentation

◆ Diamond2() [1/3]

Diamond2::Diamond2 ( const Vector2 a,
const Vector2 b 
)
explicit

Creates a diamond given the vectors defining its bounding box.

Parameters
a,bVectors.

◆ Diamond2() [2/3]

Diamond2::Diamond2 ( const Vector2 c,
const double &  r 
)
explicit

Creates a diamond given its center and axes lengths.

Parameters
cCenter.
rRadius.

◆ Diamond2() [3/3]

Diamond2::Diamond2 ( const Vector2 c,
const double &  x,
const double &  y 
)
explicit

Creates a diamond given its center and axes lengths.

Parameters
cCenter.
x,yAxes lengths.

Member Function Documentation

◆ Area()

double Diamond2::Area ( ) const

Compute the area of the diamond.

It is half the area of a box.

◆ Draw()

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

Draw a diamond.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush, should the diamond be filled.

◆ Perimeter()

double Diamond2::Perimeter ( ) const

Compute the perimeter of the diamond.

It is twice the length of the diagonal of the box.

◆ R()

double Diamond2::R ( const Vector2 p) const

Compute the squared distance between a point and the diamond.

Parameters
pPoint.

◆ Scaled()

Diamond2 Diamond2::Scaled ( const Vector2 s) const

Scales the diamond.

Parameters
sScaling vector.

◆ Translated()

Diamond2 Diamond2::Translated ( const Vector2 t) const

Translates the diamond.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 Diamond2::Vertex ( int  i) const

Return the i-th vertex.

Parameters
iVertex index.