CUGL 2.1
Cornell University Game Library
|
#include <CUSize.h>
Public Member Functions | |
Size () | |
Size (float width, float height) | |
Size (const float *array) | |
Size & | operator= (const float *array) |
Size & | set (float width, float height) |
Size & | set (const float *array) |
Size & | set (const Size other) |
int | getIWidth () const |
int | getIHeight () const |
bool | operator< (const Size v) const |
bool | operator<= (const Size v) const |
bool | operator> (const Size v) const |
bool | operator>= (const Size v) const |
bool | operator== (const Size other) const |
bool | operator!= (const Size other) const |
bool | inside (const Size other) const |
bool | contains (const Size other) const |
bool | equals (const Size other, float variance=CU_MATH_EPSILON) const |
Size & | operator+= (const Size right) |
Size & | operator-= (const Size right) |
Size & | operator*= (float a) |
Size & | operator*= (const Size right) |
Size & | operator/= (float a) |
Size & | operator/= (const Size right) |
Size | operator+ (const Size right) const |
Size | operator- (const Size right) const |
Size | operator* (float scalar) const |
Size | operator* (const Size right) const |
Size | operator/ (float scalar) const |
Size | operator/ (const Size right) const |
std::string | toString (bool verbose=false) const |
operator std::string () const | |
operator Vec2 () const | |
Size (const Vec2 point) | |
Size (const Vec2 p1, const Vec2 p2) | |
Size & | set (const Vec2 p1, const Vec2 p2) |
Size & | operator= (const Vec2 point) |
Public Attributes | |
float | width |
float | height |
Static Public Attributes | |
static const Size | ZERO |
This class defines a the size of a two dimensional box
Instances of this class may be freely cast to Vec2 and vice-versa.
This class is in standard layout with fields of uniform type. This means that it is also safe to reinterpret_cast objects to float arrays.
|
inline |
Creates a new degenerate size
The width and height of the size are zero.
|
inline |
Creates a new size with the given dimensions
width | The width value |
height | The height value |
|
inline |
Constructs a new size from the values in the specified array.
The array is read in the order width and height
array | An array containing at least two elements. |
|
explicit |
Creates a size from the given Vec2
The x coordinate is converted to width and y to height.
point | The vector to convert |
Creates the smallest size containing the two points.
p1 | The first point. |
p2 | The second point. |
|
inline |
Returns true if this size can hold the given size.
The means that all dimensions of the current size are greater than or equal to the size parameter.
other | The potentially smaller size |
|
inline |
Returns true if the sizes are within tolerance of each other.
The tolerance bound is on each axis independently.
other | The size to compare against. |
variance | The comparison tolerance. |
|
inline |
|
inline |
|
inline |
Returns true if this size fits inside of the given size.
The means that all dimensions of the current size are less than or equal to the size parameter.
other | The potentially larger size |
|
inline |
Cast from Size to a string.
|
inline |
Returns true if this size is not equal to the given size.
Comparison is exact, which may be unreliable given that the attributes are floats.
other | The vector to compare against. |
Returns the scalar product of this size with the given size.
This method is provided to support non-uniform scaling. Note: this does not modify this size.
right | The size to scale by. |
|
inline |
Returns the scalar product of this size with the given size.
Note: this does not modify this size.
scalar | The value to scale by. |
Scales this size in place by the given vector.
right | The vector to scale by |
|
inline |
Scales this size in place by the given factor.
a | The value to scale by |
Returns the sum of this size with the given size.
Note: this does not modify this size.
right | The size to add. |
Adds the given size to this one in place.
right | The size to add |
Returns the difference of this size with the given size.
Note: this does not modify this size.
right | The size to subtract. |
Subtracts the given size from this one in place.
right | The size to subtract |
Returns a copy of this size divided by the given size.
This method is provided to support non-uniform scaling. Note: this does not modify this size.
right | the size to divide this size with |
|
inline |
Returns a copy of this size divided by the given constant
Note: this does not modify this size.
scalar | the constant to divide this size with |
Divides this size in place by the given size.
This method is provided to support non-uniform scaling.
right | The size to divide by |
Size& cugl::Size::operator/= | ( | float | a | ) |
Divides this size in place by the given factor.
a | The scalar to divide by |
|
inline |
Returns true if this size is less than the given size.
This comparison uses the lexicographical order. To test if this size can properly fit inside theother, use the method inside().
v | The size to compare against. |
|
inline |
|
inline |
Sets the dimensions of this size to the contents of the given array.
The array is read in the order width and height
array | An array containing at least two elements. |
Sets the dimensions of this size to those of the given vector.
The x coordinate is converted to width and y to height.
point | The vector to convert. |
|
inline |
Returns true if this size is equal to the given size.
Comparison is exact, which may be unreliable given that the attributes are floats.
other | The vector to compare against. |
|
inline |
Determines if this size is greater than the given size.
This comparison uses the lexicographical order. To test if this size can properly hold the other vector, use the method contains().
v | The vector to compare against. |
|
inline |
Determines if this size is greater than or equal to the given size.
This comparison uses the lexicographical order. To test if this size can properly hold the other vector, use the method contains().
v | The vector to compare against. |
|
inline |
Sets the dimensions of this size from the values in the specified array.
The array is read in the order width and height
array | An array containing at least two elements. |
Sets the dimensions of this size to those in the specified size.
other | The size to copy. |
Sets this size to the smallest one containing the two points.
p1 | The first point. |
p2 | The second point. |
|
inline |
Sets the dimensions of this size to the specified values.
width | The new width value |
height | The new height value |
std::string cugl::Size::toString | ( | bool | verbose = false | ) | const |
Returns a string representation of this size for debugging purposes.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
verbose | Whether to include class information |
float cugl::Size::height |
Height of the Size object.
float cugl::Size::width |
Width of the Size object.
|
static |
The degnerate Size(0,0).