Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Math class that represents an axis-aligned rectangle in two dimensions. More...
Public Member Functions | |
Rect (T Width, T Height) | |
Constructs a Rect object from its width and height. More... | |
Rect (T X, T Y, T Width, T Height) | |
Constructs a Rect object from its position, width and height. More... | |
Rect (const T rect[4]) | |
Constructs a Rect object from an array of four elements. More... | |
Rect (const Vector2< T > &lengths) | |
Constructs a Rect object from a vector representing width and height. More... | |
Rect (const Vector2< T > &vec1, const Vector2< T > &vec2) | |
Constructs a Rect object from two vectors representing point of the space (X, Y) will be the components minimum of the two vectors and the width and height will be the components maximum - minimum. More... | |
template<typename U > | |
Rect (const Rect< U > &rect) | |
Constructs a Rect object from another type of Rect. More... | |
Rect (const Rect &rect)=default | |
bool | Contains (T X, T Y) const |
Tests whether the rectangle contains the provided point inclusive of the edge of the rectangle. More... | |
bool | Contains (const Rect &rect) const |
Tests whether the rectangle contains the provided rectangle inclusive of the edge of the rectangle. More... | |
bool | Contains (const Vector2< T > &point) const |
Tests whether the rectangle contains the provided point inclusive of the edge of the rectangle. More... | |
Rect & | ExtendTo (T X, T Y) |
Extends the rectangle to contain the point in the boundary. More... | |
Rect & | ExtendTo (const Rect &rect) |
Extends the rectangle to contain the rectangle. More... | |
Rect & | ExtendTo (const Vector2< T > &point) |
Extends the rectangle to contain the point in the boundary. More... | |
Vector2< T > | GetCenter () const |
Gets a Vector2 for the center. More... | |
Vector2< T > | GetCorner (RectCorner corner) const |
Gets the Vector2 for the corner. More... | |
Vector2< T > | GetLengths () const |
Gets a Vector2 for the lengths. More... | |
Vector2< T > | GetMaximum () const |
Gets a Vector2 for the maximum point. More... | |
Vector2< T > | GetMinimum () const |
Gets a Vector2 for the minimum point. More... | |
Vector2< T > | GetNegativeVertex (const Vector2< T > &normal) const |
Computes the negative vertex of one direction. More... | |
Vector2< T > | GetPosition () const |
Gets a Vector2 for the position. More... | |
Vector2< T > | GetPositiveVertex (const Vector2< T > &normal) const |
Computes the positive vertex of one direction. More... | |
bool | Intersect (const Rect &rect, Rect *intersection=nullptr) const |
Checks whether or not this rectangle intersects another one. More... | |
bool | IsValid () const |
Checks whether this rectangle is valid. More... | |
Rect & | MakeZero () |
Makes the rectangle position (0, 0) and lengths (0, 0) More... | |
Rect & | Set (T Width, T Height) |
Sets the components of the rectangle with width and height. More... | |
Rect & | Set (T X, T Y, T Width, T Height) |
Sets the components of the rectangle. More... | |
Rect & | Set (const T rect[4]) |
Sets the components of the rectangle from an array of four elements. More... | |
Rect & | Set (const Rect< T > &rect) |
Sets the components of the rectangle with components from another. More... | |
Rect & | Set (const Vector2< T > &lengths) |
Sets the components of the rectange from a vector representing width and height. More... | |
Rect & | Set (const Vector2< T > &vec1, const Vector2< T > &vec2) |
Sets a Rect object from two vectors representing point of the space (X, Y) will be the components minimum of the two vectors and the width and height will be the components maximum - minimum. More... | |
template<typename U > | |
Rect & | Set (const Rect< U > &rect) |
String | ToString () const |
Gives a string representation. More... | |
Rect & | Translate (const Vector2< T > &translation) |
Translates the rectangle. More... | |
T & | operator[] (std::size_t i) |
Returns the ith element of the rectangle. More... | |
T | operator[] (std::size_t i) const |
Returns the ith element of the rectangle. More... | |
Rect | operator* (T scalar) const |
Multiplies the lengths with the scalar. More... | |
Rect | operator* (const Vector2< T > &vec) const |
Multiplies the lengths with the vector. More... | |
Rect | operator/ (T scalar) const |
Divides the lengths with the scalar. More... | |
Rect | operator/ (const Vector2< T > &vec) const |
Divides the lengths with the vector. More... | |
Rect & | operator= (const Rect &other)=default |
Rect & | operator*= (T scalar) |
Multiplies the lengths of this rectangle with the scalar. More... | |
Rect & | operator*= (const Vector2< T > &vec) |
Multiplies the lengths of this rectangle with the vector. More... | |
Rect & | operator/= (T scalar) |
Divides the lengths of this rectangle with the scalar. More... | |
Rect & | operator/= (const Vector2< T > &vec) |
Divives the lengths of this rectangle with the vector. More... | |
bool | operator== (const Rect &rect) const |
Compares the rectangle to other one. More... | |
bool | operator!= (const Rect &rect) const |
Compares the rectangle to other one. More... | |
template<typename U > | |
Rect< T > & | Set (const Rect< U > &rect) |
Sets the components of the rectangle from another type of Rect. More... | |
Static Public Member Functions | |
static Rect | Lerp (const Rect &from, const Rect &to, T interpolation) |
Interpolates the rectangle to other one with a factor of interpolation. More... | |
static Rect | Zero () |
Shorthand for the rectangle (0, 0, 0, 0) More... | |
Public Attributes | |
T | x |
T | y |
T | width |
T | height |
Math class that represents an axis-aligned rectangle in two dimensions.
Constructs a Rect object from its width and height.
Width | Width of the rectangle (following X) |
Height | Height of the rectangle (following Y) |
Constructs a Rect object from its position, width and height.
X | X position |
Y | Y position |
Width | Width of the rectangle (following X) |
Height | Height of the rectangle (following Y) |
Constructs a Rect object from an array of four elements.
vec[4] | vec[0] is X position, vec[1] is Y position, vec[2] is width and vec[3] is height |
Constructs a Rect object from a vector representing width and height.
lengths | (Width, Height) of the rectangle |
Constructs a Rect object from two vectors representing point of the space (X, Y) will be the components minimum of the two vectors and the width and height will be the components maximum - minimum.
vec1 | First point |
vec2 | Second point |
bool Nz::Rect< T >::Contains | ( | T | X, |
T | Y | ||
) | const |
Tests whether the rectangle contains the provided point inclusive of the edge of the rectangle.
X | X position of the point |
Y | Y position of the point |
Tests whether the rectangle contains the provided rectangle inclusive of the edge of the rectangle.
rect | Other rectangle to test |
Tests whether the rectangle contains the provided point inclusive of the edge of the rectangle.
point | Position of the point |
Extends the rectangle to contain the point in the boundary.
X | X position of the point |
Y | Y position of the point |
Extends the rectangle to contain the rectangle.
rect | Other rectangle to contain |
Extends the rectangle to contain the point in the boundary.
point | Position of the point |
Gets a Vector2 for the center.
Gets a Vector2 for the lengths.
Gets a Vector2 for the minimum point.
Vector2< T > Nz::Rect< T >::GetNegativeVertex | ( | const Vector2< T > & | normal | ) | const |
Computes the negative vertex of one direction.
normal | Vector indicating a direction |
Gets a Vector2 for the position.
Vector2< T > Nz::Rect< T >::GetPositiveVertex | ( | const Vector2< T > & | normal | ) | const |
Computes the positive vertex of one direction.
normal | Vector indicating a direction |
bool Nz::Rect< T >::Intersect | ( | const Rect< T > & | rect, |
Rect< T > * | intersection = nullptr |
||
) | const |
Checks whether or not this rectangle intersects another one.
rect | Rectangle to check |
intersection | Optional argument for the rectangle which represent the intersection |
bool Nz::Rect< T >::IsValid | ( | ) | const |
Checks whether this rectangle is valid.
|
static |
Interpolates the rectangle to other one with a factor of interpolation.
from | Initial rectangle |
to | Target rectangle |
interpolation | Factor of interpolation |
Makes the rectangle position (0, 0) and lengths (0, 0)
Compares the rectangle to other one.
rect | Other rectangle to compare with |
Multiplies the lengths with the scalar.
scalar | The scalar to multiply width and height with |
Multiplies the lengths with the vector.
vec | The vector where component one multiply width and two height |
Multiplies the lengths of this rectangle with the scalar.
scalar | The scalar to multiply width and height with |
Multiplies the lengths of this rectangle with the vector.
vec | The vector where component one multiply width and two height |
Divides the lengths with the scalar.
scalar | The scalar to divide width and height with |
Divides the lengths with the vector.
vec | The vector where component one divide width and two height |
Divides the lengths of this rectangle with the scalar.
scalar | The scalar to divide width and height with |
Divives the lengths of this rectangle with the vector.
vec | The vector where component one divide width and two height |
Compares the rectangle to other one.
rect | Other rectangle to compare with |
T & Nz::Rect< T >::operator[] | ( | std::size_t | i | ) |
Returns the ith element of the rectangle.
std::domain_error | if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 |
T Nz::Rect< T >::operator[] | ( | std::size_t | i | ) | const |
Returns the ith element of the rectangle.
std::domain_error | if NAZARA_MATH_SAFE is defined and one of you try to acces to index greather than 4 |
Sets the components of the rectangle with width and height.
Width | Width of the rectangle (following X) |
Height | Height of the rectangle (following Y) |
Sets the components of the rectangle.
X | X position |
Y | Y position |
Width | Width of the rectangle (following X) |
Height | Height of the rectangle (following Y) |
Sets the components of the rectangle from an array of four elements.
rect[4] | rect[0] is X position, rect[1] is Y position, rect[2] is width and rect[3] is height |
Sets the components of the rectangle with components from another.
rect | The other Rect |
Sets the components of the rectange from a vector representing width and height.
lengths | (Width, Height) of the rectangle |
Rect< T > & Nz::Rect< T >::Set | ( | const Vector2< T > & | vec1, |
const Vector2< T > & | vec2 | ||
) |
Sets a Rect object from two vectors representing point of the space (X, Y) will be the components minimum of the two vectors and the width and height will be the components maximum - minimum.
vec1 | First point |
vec2 | Second point |
Sets the components of the rectangle from another type of Rect.
rect | Rectangle of type U to convert its components |
Gives a string representation.
Translates the rectangle.
translation | Vector2 which is the translation for the position |
Shorthand for the rectangle (0, 0, 0, 0)