Core 1.0
OrientedBox2 Class Reference

An oriented box. More...

#include <framebox.h>

Inheritance diagram for OrientedBox2:
Frame2

Public Member Functions

 OrientedBox2 ()
 Empty.
 
 OrientedBox2 (const Vector2 &, const Vector2 &, const Vector2 &=Vector2::X)
 Creates an oriented box.
 
 OrientedBox2 (const Box2 &, const Frame2 &=Frame2::Id)
 Creates an oriented box.
 
 OrientedBox2 (const Vector2 &, const Frame2 &=Frame2::Id)
 Creates an oriented box.
 
 ~OrientedBox2 ()
 Empty.
 
double R (const Vector2 &) const
 Compute the squared Euclidean distance to the box.
 
double Signed (const Vector2 &) const
 Compute the squared Euclidean distance to the box.
 
OrientedBox2 Translated (const Vector2 &) const
 Return a box translated by a given vector.
 
OrientedBox2 Rotated (const Matrix2 &) const
 Return a box rotated by a given matrix.
 
OrientedBox2 Transformed (const Frame2 &) const
 Return a box transformed by a frame.
 
bool Intersect (const Ray2 &, double &, double &) const
 Check the intersection between the box and a ray.
 
bool Intersect (const Ray2 &) const
 Check the intersection between the box and a ray.
 
const Vector2 Center () const
 Return the center of the oriented box.
 
Vector2 Vertex (int) const
 Returns the k-th vertex of the oriented box.
 
Box2 GetBox () const
 Compute the axis aligned bounding box enclosing the oriented box.
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draws an oriented box.
 

Static Public Attributes

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

Protected Attributes

Vector2 length = Vector2::Null
 Half diagonal vector.
 
- Protected Attributes inherited from Frame2
Matrix2 r
 Rotation matrix.
 
Vector2 t
 Translation vector.
 

Additional Inherited Members

- Protected Member Functions inherited from Frame2
 Frame2 (const Matrix2 &=Matrix2::Identity, const Vector2 &=Vector2::Null)
 Creates a frame given a rotation matrix and a translation vector.
 
 Frame2 (const double &, const Vector2 &=Vector2::Null)
 Creates a frame given a rotation angle and a translation vector.
 
 Frame2 (const Vector2 &, const Vector2 &)
 Creates a frame given the origin and its orthogonal unit vectors.
 
 ~Frame2 ()
 Empty.
 
Matrix2 R () const
 Returns the rotation matrix of the frame.
 
Vector2 T () const
 Returns the translation vector of the frame.
 
void Compose (const Frame2 &)
 Compose the frame with another one.
 
Frame2 Composed (const Frame2 &) const
 Compose the frame with another one.
 
Frame2 Inverse () const
 Compute the inverse transformation.
 
Vector2 Transform (const Vector2 &) const
 Transform a point out of the frame coordinate system.
 
Vector2 InverseTransform (const Vector2 &) const
 Transform a point into the frame coordinate system.
 
Vector2 TransformDirection (const Vector2 &) const
 Transform a direction vector out of the frame coordinate system.
 
Vector2 InverseTransformDirection (const Vector2 &) const
 Transform a direction vector into the frame coordinate system.
 
void Draw (QGraphicsScene &, const QPen &) const
 Draw a circle.
 
- Static Protected Member Functions inherited from Frame2
static Frame2 Translation (const Vector2 &)
 Creates a translation transformation.
 
static Frame2 Rotation (const double &)
 Create a rotation frame.
 
- Static Protected Attributes inherited from Frame2
static const Frame2 Id
 Identity.
 

Detailed Description

An oriented box.

Constructor & Destructor Documentation

◆ OrientedBox2() [1/3]

OrientedBox2::OrientedBox2 ( const Vector2 & c,
const Vector2 & half,
const Vector2 & x = Vector2::X )
explicit

Creates an oriented box.

Parameters
cCenter.
halfHalf size of the box (half diagonal).
xAxis, should be unit.

◆ OrientedBox2() [2/3]

OrientedBox2::OrientedBox2 ( const Box2 & box,
const Frame2 & frame = Frame2::Id )
explicit

Creates an oriented box.

Parameters
boxBox.
frameFrame.

◆ OrientedBox2() [3/3]

OrientedBox2::OrientedBox2 ( const Vector2 & half,
const Frame2 & frame = Frame2::Id )
explicit

Creates an oriented box.

Parameters
halfHalf size of the box (half diagonal).
frameFrame.

Member Function Documentation

◆ Draw()

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

Draws an oriented box.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ Intersect() [1/2]

bool OrientedBox2::Intersect ( const Ray2 & ray) const

Check the intersection between the box and a ray.

Parameters
rayThe (normalized) ray.

◆ Intersect() [2/2]

bool OrientedBox2::Intersect ( const Ray2 & ray,
double & ta,
double & tb ) const

Check the intersection between the box and a ray.

Note that intersections are sorted.

This function assumes that the ray is normalized, i.e. has a unit direction vector.

Parameters
rayThe (normalized) ray.
ta,tbIntersection depths.

◆ R()

double OrientedBox2::R ( const Vector2 & p) const

Compute the squared Euclidean distance to the box.

Parameters
pPoint.

◆ Rotated()

OrientedBox2 OrientedBox2::Rotated ( const Matrix2 & r) const

Return a box rotated by a given matrix.

Parameters
rRotation matrix.

◆ Signed()

double OrientedBox2::Signed ( const Vector2 & p) const

Compute the squared Euclidean distance to the box.

See also
Box2::Signed(const Vector2&) const
Parameters
pPoint.

◆ Transformed()

OrientedBox2 OrientedBox2::Transformed ( const Frame2 & f) const

Return a box transformed by a frame.

Parameters
fTransformation.

◆ Translated()

OrientedBox2 OrientedBox2::Translated ( const Vector2 & t) const

Return a box translated by a given vector.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 OrientedBox2::Vertex ( int k) const
inline

Returns the k-th vertex of the oriented box.

Parameters
kIndex.