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

An oriented box. More...

#include <framebox.h>

Inheritance diagram for OrientedBox2:
Frame2

Public Member Functions

 OrientedBox2 ()
 Empty.
 
 OrientedBox2 (const Box2 &, const Frame2 &=Frame2::Id)
 Creates an oriented box. More...
 
 OrientedBox2 (const Vector2 &, const Frame2 &=Frame2::Id)
 Creates an oriented box. More...
 
 ~OrientedBox2 ()
 Empty.
 
double R (const Vector2 &) const
 Compute the squared Euclidean distance to the box. More...
 
double Signed (const Vector2 &) const
 Compute the squared Euclidean distance to the box. More...
 
OrientedBox2 Translated (const Vector2 &) const
 Return a box translated by a given vector. More...
 
OrientedBox2 Rotated (const Matrix2 &) const
 Return a box rotated by a given matrix. More...
 
OrientedBox2 Transformed (const Frame2 &) const
 Return a box transformed by a frame. More...
 
bool Intersect (const Ray2 &, double &, double &) const
 Check the intersection between the box and a ray. More...
 
bool Intersect (const Ray2 &) const
 Check the intersection between the box and a ray. More...
 
const Vector2 Center () const
 Return the center of the oriented box.
 
Vector2 Vertex (int) const
 Returns the k-th vertex of the oriented box. More...
 
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. More...
 

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. More...
 
 Frame2 (const Vector2 &, const Vector2 &, const Vector2 &)
 Creates a frame given the origin and its orthogonal unit vectors. More...
 
 ~Frame2 ()
 Empty.
 
Matrix2 R () const
 Returns the rotation matrix of the frame.
 
Vector2 T () const
 Returns the translation vector of the frame.
 
Vector2 GetVector (int) const
 Returns the i-th basis vector of the frame. More...
 
void Compose (const Frame2 &)
 Compose the frame with another one. More...
 
Frame2 Composed (const Frame2 &) const
 Compose the frame with another one. More...
 
Frame2 Inverse () const
 Compute the inverse transformation.
 
Vector2 Transform (const Vector2 &) const
 Transform a point out of the frame coordinate system. More...
 
Vector2 InverseTransform (const Vector2 &) const
 Transform a point into the frame coordinate system. More...
 
Vector2 TransformDirection (const Vector2 &) const
 Transform a direction vector out of the frame coordinate system. More...
 
Vector2 InverseTransformDirection (const Vector2 &) const
 Transform a direction vector into the frame coordinate system.
 
- Static Protected Member Functions inherited from Frame2
static Frame2 Translation (const Vector2 &)
 Creates a translation transformation. More...
 
static Frame2 Rotation (const double &)
 Create a rotation frame about an arbitrary axis. More...
 
- Static Protected Attributes inherited from Frame2
static const Frame2 Id
 Identity.
 

Detailed Description

An oriented box.

Constructor & Destructor Documentation

◆ OrientedBox2() [1/2]

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

Creates an oriented box.

Parameters
boxBox.
frameFrame.

◆ OrientedBox2() [2/2]

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.