scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
|
Class that allows to store and calculate size in 2D, with width and height. The template parameter T allows to select any scalar_unit or numeric type to be the type of width and height (they always have the same type in the same instance). The width and height can be any scalar_unit, usually length, but imaginary spaces with custom dimensions are also allowed. Initialization string example: "1 m * 2 m". More...
#include <size_2d.hpp>
Public Member Functions | |
size_2d () | |
Default constructor. Both width and height are initialized to 0, with the dimensions to the default of their base unit. | |
size_2d (const size_2d< T > &x) | |
Copy constructor. The width and height are copied from the size_2d<T> x. | |
size_2d (size_2d< T > &&x) | |
Move constructor. The width and height are moved from the size_2d<T> x. | |
size_2d (const scalar_unit &new_width, const scalar_unit &new_height) | |
size_2d (const string &new_width, const string &new_height) | |
Constructor. width is new_width and height is new_height, they are initialized by string. | |
size_2d (const string &init_size_2d) | |
Constructor. The member-variables are initialized by the initialization string init_size_2d. | |
size_2d< T > & | operator= (const size_2d< T > &x) |
Copy assignment. The width and height are copied from the size_2d<T> x. | |
size_2d< T > & | operator= (size_2d< T > &&x) |
Move assignment. The width and height are moved from the size_2d<T> x. | |
size_2d< T > & | operator= (const string &init_size_2d) |
Assignment. The member-variables are initialized by the initialization string init_size_2d. | |
template<typename U > | |
size_2d< T > | operator+ (const size_2d< U > &x) const |
Creates a new size_2d<T> by the addition of two size_2d<T> classes. The width is the result of the addition of the two width of the size_2d<T> classes and the height the result of the addition of the two height of the size_2d<T> classes. | |
template<typename U > | |
size_2d< T > | operator- (const size_2d< U > &x) const |
Creates a new size_2d<T> by the difference of two size_2d<T> classes. The width is the result of the difference of the two width of the size_2d<T> classes and the height the result of the difference of the two height of the size_2d<T> classes. | |
template<typename U > | |
void | operator+= (const size_2d< U > &x) |
Sums the width of size_2d<T> x to the width and sums the height of size_2d<T> x to the height. | |
template<typename U > | |
void | operator-= (const size_2d< U > &x) |
Substracts the width of size_2d<T> x to the width and substracts the height of size_2d<T> x to the height. | |
scalar_unit | get_area () const |
Calculates the area as the multiplication of the width and height. | |
string | display () const |
Returns a string representation of size_2d<T>, with his width and height. | |
Public Attributes | |
T | width |
Width, usually stored as length. | |
T | height |
Height, usually stored as length. | |
Private Member Functions | |
void | initialize_from_string (const string &init_size_2d) |
Internal function. Initializes the member-variables with an initialization string of size_2d<T>. | |
Class that allows to store and calculate size in 2D, with width and height. The template parameter T allows to select any scalar_unit or numeric type to be the type of width and height (they always have the same type in the same instance). The width and height can be any scalar_unit, usually length, but imaginary spaces with custom dimensions are also allowed. Initialization string example: "1 m * 2 m".
Definition at line 16 of file size_2d.hpp.
Default constructor. Both width and height are initialized to 0, with the dimensions to the default of their base unit.
Definition at line 19 of file size_2d.hpp.
Copy constructor. The width and height are copied from the size_2d<T> x.
Definition at line 22 of file size_2d.hpp.
Move constructor. The width and height are moved from the size_2d<T> x.
Definition at line 25 of file size_2d.hpp.
|
inlineexplicit |
Definition at line 28 of file size_2d.hpp.
Constructor. width is new_width and height is new_height, they are initialized by string.
Definition at line 31 of file size_2d.hpp.
Constructor. The member-variables are initialized by the initialization string init_size_2d.
Definition at line 34 of file size_2d.hpp.
Returns a string representation of size_2d<T>, with his width and height.
Definition at line 90 of file size_2d.hpp.
|
inline |
Calculates the area as the multiplication of the width and height.
Definition at line 85 of file size_2d.hpp.
Internal function. Initializes the member-variables with an initialization string of size_2d<T>.
Definition at line 101 of file size_2d.hpp.
Creates a new size_2d<T> by the addition of two size_2d<T> classes. The width is the result of the addition of the two width of the size_2d<T> classes and the height the result of the addition of the two height of the size_2d<T> classes.
Definition at line 60 of file size_2d.hpp.
Sums the width of size_2d<T> x to the width and sums the height of size_2d<T> x to the height.
Definition at line 72 of file size_2d.hpp.
Creates a new size_2d<T> by the difference of two size_2d<T> classes. The width is the result of the difference of the two width of the size_2d<T> classes and the height the result of the difference of the two height of the size_2d<T> classes.
Definition at line 66 of file size_2d.hpp.
Substracts the width of size_2d<T> x to the width and substracts the height of size_2d<T> x to the height.
Definition at line 79 of file size_2d.hpp.
Copy assignment. The width and height are copied from the size_2d<T> x.
Definition at line 39 of file size_2d.hpp.
Assignment. The member-variables are initialized by the initialization string init_size_2d.
Definition at line 53 of file size_2d.hpp.
Move assignment. The width and height are moved from the size_2d<T> x.
Definition at line 46 of file size_2d.hpp.
Height, usually stored as length.
Definition at line 98 of file size_2d.hpp.
Width, usually stored as length.
Definition at line 97 of file size_2d.hpp.