|
Core 1.0
|
Axis aligned box in the plane. More...
#include <box.h>
Public Member Functions | |
| Box2 () | |
| Empty. | |
| Box2 (const double &) | |
| Create a square box centered at the origin and of given half side length. | |
| Box2 (const double &, const double &) | |
| Create a box centered at the origin and of given dimensions. | |
| Box2 (const Vector2 &) | |
| Create a box from a single vertex. | |
| Box2 (const Vector2 &, const Vector2 &) | |
| Create a box. | |
| Box2 (const Vector2 &, const double &) | |
| Creates a box. | |
| Box2 (const Vector2 &, const double &, const double &) | |
| Create a box given a center point and its width, length, and height. | |
| Box2 (const Box &) | |
| Create a box in the plane given a box. | |
| Box2 (const Box2 &, const Box2 &) | |
| Create a box embedding two boxes. | |
| Box2 (const Box2 &, const Matrix2 &) | |
| Creates an axis aligned bounding box from a box and a transformation matrix. | |
| Box2 (const Box2 &, const Frame2 &) | |
| Creates an axis aligned bounding box from a box and a frame. | |
| Box2 (const QVector< Vector2 > &) | |
| Compute the bounding box of a set of points. | |
| Box2 (const QSize &) | |
| Create a box from a Qt size. | |
| Vector2 & | operator[] (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. | |
| double | Height () const |
| Compute the height of a box. | |
| 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. | |
| Vector2 | Vertex (int, int, int, int) const |
| Compute the coordinates of a grid aligned point. | |
| Vector2 | VertexUV (const Vector2 &) const |
| Compute the coordinates of a point inside the box given uv coordinates. | |
| Box2 | Sub (int) const |
| Computes the sub-box in the n-th quadrant. | |
| double | R (const Vector2 &) const |
| Compute the squared distance between the box and a point. | |
| double | Signed (const Vector2 &) const |
| Computes the signed distance between the box and a point. | |
| double | R (const Box2 &) const |
| Compute the squared Euclidean distance between two boxes. | |
| void | Translate (const Vector2 &) |
| Translates a box. | |
| void | Scale (const Vector2 &) |
| Scales a box. | |
| void | Scale (const double &) |
| Scales a box. | |
| Box2 | Translated (const Vector2 &) const |
| Translated box. | |
| Box2 | Scaled (const double &) const |
| Scales a box and return the scaled box. | |
| Box2 | Scaled (const Vector2 &) const |
| Scales a box and return the scaled box. | |
| Box2 | Scaled (const QSize &) const |
| Scales a box according to a Qt size. | |
| Box2 | ScaledTo (const double &) const |
| Scale the box so that the largest side should equal the argument value. | |
| Box2 | ScaledCentered (const double &) const |
| Scales a box while preserving its center. | |
| Box2 | Rotated (const double &) const |
| Compute the box embedding the rotated box. | |
| Box2 | Rotated (const Matrix2 &) const |
| Compute the box embedding the rotated box. | |
| Box2 | Centered () const |
| Compute the box translated to origin. | |
| void | SetCubic () |
| Creates the tightest embedding cube from an arbitrarilly shaped box. | |
| void | SetInscribedCubic () |
| Creates the biggest cube inscribed in the box. | |
| Box2 | Cube () const |
| Return the tightest embedding cube from an arbitrarilly shaped box. | |
| void | Extend (const double &) |
| Extend the limits of the box by a given distance. | |
| void | Extend (const Vector2 &) |
| Extend the limits of the box given a point. | |
| Box2 | Extended (const double &) const |
| Extend the limits of the box by a given distance. | |
| void | SetParallelepipedic (int, int &, int &) |
| Inflates a box so that its dimensions should be a fraction of its maximum side length. | |
| void | SetParallelepipedic (const double &, int &, int &) |
| Creates a parallelepipedic box whose dimensions are integer multiples of a given input reference size. | |
| bool | Inside (const Vector2 &) const |
| Test if a point is inside the box. | |
| bool | Inside (const Vector2 &, const double &) const |
| Test if a point lies withing a given range of the box. | |
| bool | Intersect (const Box2 &) const |
| Check if the box intersects another box. | |
| double | OverlapArea (const Box2 &) const |
| Computes the overlapping area of two boxes. | |
| Box2 | Intersection (const Box2 &) const |
| Computes the intersection between two boxes. | |
| Box | ToBox (const double &, const double &) const |
| Convert a planar Box2 to a Box. | |
| int | Quadrant (const Vector2 &) const |
| Computes quadrant index of a vertex with respect to the box center. | |
| bool | Intersect (const Ray2 &, double &, double &) const |
| Computes the intersection between a box and a ray. | |
| bool | Intersect (const Ray2 &) const |
| Computes the intersection between a box and a ray. | |
| bool | Intersect (const Line2 &, double &, double &) const |
| Computes the intersection between a box and a line. | |
| bool | Intersect (const Segment2 &, double &, double &) const |
| Compute the intersection between a box and a segment. | |
| bool | Intersect (const Line2 &) const |
| Check the intersection between a box and a line. | |
| bool | Intersect (const Segment2 &) const |
| Check the intersection between a box and a segment. | |
| void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
| Draw a rectangle. | |
| Vector2 | RandomInside (Random &=Random::R239) const |
| Generate a random vector inside the box. | |
| Vector2 | RandomOn (Random &=Random::R239) const |
| Generate a random vector on the perimeter of the box. | |
| 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. | |
| Box2 | Tile (int, int) const |
| Return the tiled the box using integer coordinates. | |
| Box2 | Tile (const QRect &) const |
| Return the tiled the box using integer coordinates. | |
| Segment2 | GetSegment (const double &, bool=true) const |
| Compute the horizontal or vertical segment dividing the box into u and 1-u parts. | |
| QVector< Vector2 > | Poisson (const double &, int, Random &=Random::R239) const |
| Compute a Poisson disc distribution inside a box. | |
| QVector< Vector2 > | Poisson (const double &, int, const QVector< Vector2 > &, bool=true, Random &=Random::R239) const |
| Compute a Poisson disc distribution inside a box. | |
Static Public Member Functions | |
| static Box2 | MinMax (const Vector2 &, const Vector2 &) |
| Create a box from any two points. | |
Static Public Attributes | |
| 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. | |
| static const Box2 | Unit |
| Unit box, defined as. | |
Protected Attributes | |
| Vector2 | b = Vector2(1.0) |
| Lower and upper vertexes of the box. | |
Friends | |
| bool | operator== (const Box2 &a, const Box2 &b) |
| Check if two boxes are (strictly) equal. | |
| bool | operator!= (const Box2 &a, const Box2 &b) |
| Check if two boxes are (strictly) different. | |
| Box2 | operator+ (const Box2 &a, const Box2 &b) |
| Computes the Minkowski sum of two boxes. | |
| Box2 | operator* (const double &t, const Box2 &box) |
| Scales a box by a scalar factor. | |
| Box2 | operator* (const Box2 &box, const double &t) |
| Overloaded. | |
| std::ostream & | operator<< (std::ostream &s, const Box2 &box) |
| Overloaded. | |
Axis aligned box in the plane.
|
inlineexplicit |
Create a square box centered at the origin and of given half side length.
This is equivalent to:
| r | Half side length. |
|
inlineexplicit |
|
inlineexplicit |
Create a box from a single vertex.
| p | Point. |
Create a box.
Note that is possible to create a box using Vector as parameters as the compiler will call the constructor Vector2::Vector2(const Vector&).
| a,b | Points. |
|
inlineexplicit |
Creates a box.
| c | Center. |
| r | Radius. |
|
inlineexplicit |
Create a box given a center point and its width, length, and height.
| c | center. |
| x,y | Width and height. |
|
inlineexplicit |
Create a box in the plane given a box.
| box | The box. |
Create a box embedding two boxes.
| x,y | Argument boxes. |
Creates an axis aligned bounding box from a box and a transformation matrix.
| box | The box. |
| t | Transformation matrix. |
Creates an axis aligned bounding box from a box and a frame.
| box | The box. |
| frame | Transformation. |
|
explicit |
Compute the bounding box of a set of points.
| p | Set of points (should not be empty). |
|
explicit |
Create a box from a Qt size.
| size | Size. |
| Box2 Box2::Centered | ( | ) | const |
| Box2 Box2::Cube | ( | ) | const |
Return the tightest embedding cube from an arbitrarilly shaped box.
| void Box2::Draw | ( | QGraphicsScene & | scene, |
| const QPen & | pen = QPen(), | ||
| const QBrush & | brush = QBrush() ) const |
Draw a rectangle.
| scene | Graphics scene. |
| pen | The pen. |
| brush | The brush, should the box be filled. |
| void Box2::Extend | ( | const double & | r | ) |
Extend the limits of the box by a given distance.
Note that this is the same as performing the Minkowski sum with a cubic box of size r.
| r | Range. |
| void Box2::Extend | ( | const Vector2 & | p | ) |
Extend the limits of the box given a point.
If the point lies inside the box, the vertices of the box are unchanged.
| p | Point. |
| Box2 Box2::Extended | ( | const double & | r | ) | const |
Extend the limits of the box by a given distance.
Note that this is the same as performing the Minkowski sum with a cubic box of size r.
| r | Range. |
| Segment2 Box2::GetSegment | ( | const double & | u, |
| bool | horizontal = true ) const |
Compute the horizontal or vertical segment dividing the box into u and 1-u parts.
| u | Real. |
| horizontal | Boolean, set to true for horizontal split, false for vertical. |
|
inline |
Compute the height of a box.
| bool Box2::Inside | ( | const Vector2 & | p | ) | const |
Test if a point is inside the box.
| p | Point. |
| bool Box2::Inside | ( | const Vector2 & | p, |
| const double & | r ) const |
Test if a point lies withing a given range of the box.
The following two pieces of code are almost equivalent:
In this case we modify the geometry:
| p | Point. |
| r | Range. |
|
inline |
Check if the box intersects another box.
| box | Argument box. |
| bool Box2::Intersect | ( | const Line2 & | l | ) | const |
Check the intersection between a box and a line.
This function is a convenience fuction for:
| l | The line. |
| bool Box2::Intersect | ( | const Line2 & | s, |
| double & | tmin, | ||
| double & | tmax ) const |
Computes the intersection between a box and a line.
Sorted intersection depths are returned if intersection occurs.
| s | The line. |
| tmin,tmax | Intersection depths |
| bool Box2::Intersect | ( | const Ray2 & | ray | ) | const |
Computes the intersection between a box and a ray.
| ray | The ray. |
| bool Box2::Intersect | ( | const Ray2 & | ray, |
| double & | tmin, | ||
| double & | tmax ) const |
Computes the intersection between a box and a ray.
| ray | The ray. |
| tmin,tmax | Intersection depths |
| bool Box2::Intersect | ( | const Segment2 & | s | ) | const |
Check the intersection between a box and a segment.
| s | The segment. |
| bool Box2::Intersect | ( | const Segment2 & | s, |
| double & | tmin, | ||
| double & | tmax ) const |
Compute the intersection between a box and a segment.
| s | The line. |
| tmin,tmax | Intersection depths |
Computes the intersection between two boxes.
Note that if the intersection is empty, the resulting box is invalid.
| x | Argument box. |
Create a box from any two points.
| a,b | Points. |
|
inline |
Computes the overlapping area of two boxes.
This is a convenience function for the following code:
| box |
| QVector< Vector2 > Box2::Poisson | ( | const double & | r, |
| int | n, | ||
| const QVector< Vector2 > & | s, | ||
| bool | a = true, | ||
| Random & | random = Random::R239 ) const |
Compute a Poisson disc distribution inside a box.
This function uses a simple dart throwing algorithm.
| r | Radius of the discs. |
| n | Number of candidate points. |
| s | Set of points. |
| a | Add set of points flag: set to true it the set points should be added to the sampling, set to false to define constraints (typically for borders). |
| random | Random number generator. |
| QVector< Vector2 > Box2::Poisson | ( | const double & | r, |
| int | n, | ||
| Random & | random = Random::R239 ) const |
Compute a Poisson disc distribution inside a box.
This function uses a simple dart throwing algorithm.
| r | Radius of the discs. |
| n | Number of candidate points. |
| random | Random number generator. |
| int Box2::Quadrant | ( | const Vector2 & | p | ) | const |
Computes quadrant index of a vertex with respect to the box center.
| p | Point. |
| double Box2::R | ( | const Box2 & | y | ) | const |
Compute the squared Euclidean distance between two boxes.
This function computes the squared distance to avoid the computation of a square root.
| y | The box. |
| double Box2::R | ( | const Vector2 & | p | ) | const |
Compute the squared distance between the box and a point.
| p | Point. |
| Vector2 Box2::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the box.
| random | Random number generator. |
| Vector2 Box2::RandomOn | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector on the perimeter of the box.
| random | Random number generator. |
| Box2 Box2::Rotated | ( | const double & | a | ) | const |
Compute the box embedding the rotated box.
| a | Rotation angle. |
Compute the box embedding the rotated box.
| r | Rotation matrix. |
| void Box2::Scale | ( | const double & | s | ) |
| void Box2::Scale | ( | const Vector2 & | s | ) |
Scales a box.
Note that this function handles negative coefficients in the scaling vector.
| s | Scaling vector. |
| Box2 Box2::Scaled | ( | const double & | s | ) | const |
Scales a box and return the scaled box.
| s | Scaling factor. |
| Box2 Box2::Scaled | ( | const QSize & | s | ) | const |
Scales a box according to a Qt size.
This function preserves the width of the box, and scales its height according to the ratio.
| s | Size. |
| Box2 Box2::ScaledCentered | ( | const double & | s | ) | const |
| Box2 Box2::ScaledTo | ( | const double & | s | ) | const |
Scale the box so that the largest side should equal the argument value.
| s | Target largest size. |
| void Box2::SetCubic | ( | ) |
Creates the tightest embedding cube from an arbitrarilly shaped box.
This function creates a cube located at the same center point, and its side length equal to the maximum side of the argument box.
| void Box2::SetInscribedCubic | ( | ) |
Creates the biggest cube inscribed in the box.
This function creates a cube located at the same center point, and its side length equal to the minimum side of the argument box.
| void Box2::SetParallelepipedic | ( | const double & | size, |
| int & | x, | ||
| int & | y ) |
Creates a parallelepipedic box whose dimensions are integer multiples of a given input reference size.
| size | Reference size, the dimension of the box will be a multiple of this size. |
| x,y | Two integers. |
| void Box2::SetParallelepipedic | ( | int | n, |
| int & | x, | ||
| int & | y ) |
Inflates a box so that its dimensions should be a fraction of its maximum side length.
| n | Fraction. |
| x,y | Two integers. |
| double Box2::Signed | ( | const Vector2 & | p | ) | const |
Computes the signed distance between the box and a point.
| p | Point. |
| Box2 Box2::Sub | ( | int | n | ) | const |
Computes the sub-box in the n-th quadrant.
| n | Quadrant index. |
| Box2 Box2::Tile | ( | const QRect & | r | ) | const |
Return the tiled the box using integer coordinates.
| r | Rectangle defining tiling coordinates. |
| Box2 Box2::Tile | ( | int | x, |
| int | y ) const |
Return the tiled the box using integer coordinates.
| x,y | Integer coordinates. |
| QRect Box2::TileRange | ( | const Box2 & | t | ) | const |
Compute the range of index for tiling the argument box so that it covers the box.
| t | Tiling box. |
| Box Box2::ToBox | ( | const double & | a, |
| const double & | b ) const |
| void Box2::Translate | ( | const Vector2 & | t | ) |
Translates a box.
| t | Translation vector. |
|
inline |
| Vector2 Box2::Vertex | ( | int | i, |
| int | j, | ||
| int | x, | ||
| int | y ) const |
Compute the coordinates of a grid aligned point.
This function computes the coordinates of a point inside the box as if the box was decomposed into a regular grid.
| i,j | Integer coordinates. |
| x,y | Virtual grid size. |
Compute the coordinates of a point inside the box given uv coordinates.
| uv | Coordinates. |
|
inline |
Compute the width of a box.
Check if two boxes are (strictly) different.
| a,b | Boxes. |
Scales a box by a scalar factor.
| t | Scaling factor. |
| box | The box. |
Computes the Minkowski sum of two boxes.
| a,b | Argument boxes. |
|
friend |
Overloaded.
| s | Stream. |
| box | The box. |
Check if two boxes are (strictly) equal.
| a,b | Boxes. |