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 work with angles. Each angle sizes 4 bytes. Initialization string example: "20°". More...
#include <angle.hpp>
Public Types | |
enum | type : int8_t { DEGREE , RADIAN , GRADIAN , TURN } |
Represents an type of angle, which can be a degree or a radian. The value of the angle inside the angle class is always stored in degrees, but can be get in radian if it's needed. More... | |
Public Member Functions | |
angle () | |
Default constructor of angle. The value is set to 0. | |
angle (const angle &x) | |
Copy constructor of angle. The value is copied from the angle x. | |
angle (angle &&x) | |
Move constructor of angle. The value is moved from the angle x. | |
angle (float new_value, angle::type init_type=angle::DEGREE) | |
Constructor of angle. The value is initialized to the float new_value. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE. | |
angle (double new_value, angle::type init_type=angle::DEGREE) | |
Constructor of angle. The value is initialized from the double new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE. | |
angle (long double new_value, angle::type init_type=angle::DEGREE) | |
Constructor of angle. The value is initialized from the long double new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE. | |
angle (int new_value, angle::type init_type=angle::DEGREE) | |
Constructor of angle. The value is initialized from the int new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE. | |
angle (const string &init_angle) | |
Constructor of angle. The value is initialized from the initialization string of angle, which uses the character 00B0 or the character 00BA to represent degrees. | |
angle (const scalar_unit &x) | |
Constructor of angle. The value is initialized from the scalar_unit x, if the scalar_unit has empty dimensions. | |
angle & | operator= (const angle &x) |
Copy assignment of angle. The value is copied to the value of angle x. | |
angle & | operator= (angle &&x) |
Move assignment of angle. The value is moved from the value of angle x. | |
angle & | operator= (float new_value) |
Assignment operator. The value is copied from the float. | |
angle & | operator= (const string &init_angle) |
Assignment operator. An initialization string is used to set the value, which contains the character 00B0 or the character 00BA to represent degrees. | |
angle & | operator= (const scalar_unit &x) |
Assignment operator. The value of the angle is set to the value of the scalar_unit x, only if the scalar_unit has empty dimensions. | |
operator float () const | |
Cast angle to a float. | |
const float & | get_value () const |
Gets the value of the angle, in degrees. | |
angle | operator+ (const angle &x) const |
Creates a new angle as the sum of other two. | |
angle | operator- (const angle &x) const |
Creates a new angle as the substraction of this angle and another angle x. | |
angle | operator* (const angle &x) const |
Creates a new angle as the multiplication of other two. | |
angle | operator/ (const angle &x) const |
Creates a new angle as the division of this angle and another angle x. | |
angle | operator^ (const angle &x) const |
Creates a new angle by powering the angle class with the value of another angle x. | |
void | operator+= (const angle &x) |
Sums the value of the angle x to the value of this angle. The value is normalized after. | |
void | operator-= (const angle &x) |
Substract the value of the angle x to the value of this angle. The value is normalized after. | |
void | operator*= (const angle &x) |
Multiplies the value of this angle with the value of angle x. The value is normalized after. | |
void | operator/= (const angle &x) |
Divides the value of this angle with the value of angle x. The value is normalized after. | |
void | operator^= (const angle &x) |
Powers the value of this angle with the value of angle x. The value is normalized after. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator= (T new_value) |
Sets the value to the value of some numeric type, casting it to a float first, and normalizing the value after that. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
angle | operator+ (T x) const |
Creates a new angle as the sum of a numeric type with the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
angle | operator- (T x) const |
Creates a new angle as the substraction of the value of this angle with a numeric type. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
angle | operator* (T x) const |
Creates a new angle as the multiplication of a numeric type with the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
angle | operator/ (T x) const |
Creates a new angle as the division of a numeric type with the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
angle | operator^ (T x) const |
Creates a new angle as the power of the value of this angle with a numeric type. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator+= (T x) |
Sums a numeric type to the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator-= (T x) |
Substracts a numeric type to the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator*= (T x) |
Multiplies a numeric type to the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator/= (T x) |
Divides a numeric type to the value of this angle. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
void | operator^= (T x) |
Powers a numeric type to the value of this angle. | |
angle & | operator++ () |
Increments the value by one. | |
angle | operator++ (int) |
Increments the value by one. | |
angle & | operator-- () |
Decrements the value by one. | |
angle | operator-- (int) |
Decrements the value by one. | |
void | invert () |
Inverts the angle to the opposite direction in a 2D plane, which is to add 180 degrees. The value is normalized after. | |
scalar_unit | to_scalar_unit () const |
Creates a scalar_unit with the same value and degree dimensions. | |
string | display (int number_of_decimals=2) const |
Creates an string from the angle, with the value and the degrees symbol. | |
float | get_degree () const |
Gets the value of the angle in degrees. | |
float | get_radian () const |
Gets the value of the angle in radians. | |
Protected Member Functions | |
void | initialize_from_string (string init_angle) |
Internal function. Sets the value of the angle to a new value using the initialization string of angles. | |
Protected Attributes | |
float | value |
Value of the angle. It is stored in degrees. | |
Private Member Functions | |
void | normalize_value () |
Internal function. Normalizes the value, which means to maintain the same angle within 0 and 360. If the value is lower or greather it gets converted to their equivalent counterpart within this range. | |
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°".
angle is a class that allows to work with angles, more in degrees than in radians. The value of the angle is always stored inside the class in degrees, and it can be get in radians with the to_radian() function.
Represents an type of angle, which can be a degree or a radian. The value of the angle inside the angle class is always stored in degrees, but can be get in radian if it's needed.
Definition at line 79 of file angle.hpp.
angle::angle | ( | ) |
angle::angle | ( | angle && | x | ) |
|
explicit |
Constructor of angle. The value is initialized to the float new_value. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE.
Definition at line 27 of file angle.cpp.
|
explicit |
Constructor of angle. The value is initialized from the double new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE.
Definition at line 48 of file angle.cpp.
|
explicit |
Constructor of angle. The value is initialized from the long double new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE.
Definition at line 69 of file angle.cpp.
|
explicit |
Constructor of angle. The value is initialized from the int new_value casted to a float. init_type is not stored as a member-variable, but instead allows to select if the value is given in DEGREE or in RADIAN. By default it's in DEGREE.
Definition at line 90 of file angle.cpp.
Constructor of angle. The value is initialized from the initialization string of angle, which uses the character 00B0 or the character 00BA to represent degrees.
Definition at line 111 of file angle.cpp.
|
explicit |
Constructor of angle. The value is initialized from the scalar_unit x, if the scalar_unit has empty dimensions.
Definition at line 116 of file angle.cpp.
Creates an string from the angle, with the value and the degrees symbol.
Definition at line 261 of file angle.cpp.
|
inline |
|
inline |
Gets the value of the angle in radians.
Internal function. Sets the value of the angle to a new value using the initialization string of angles.
Definition at line 297 of file angle.cpp.
void angle::invert | ( | ) |
Inverts the angle to the opposite direction in a 2D plane, which is to add 180 degrees. The value is normalized after.
|
private |
Internal function. Normalizes the value, which means to maintain the same angle within 0 and 360. If the value is lower or greather it gets converted to their equivalent counterpart within this range.
|
inlineexplicit |
Creates a new angle as the multiplication of other two.
Multiplies the value of this angle with the value of angle x. The value is normalized after.
angle & angle::operator++ | ( | ) |
Increments the value by one.
Sums the value of the angle x to the value of this angle. The value is normalized after.
angle & angle::operator-- | ( | ) |
Decrements the value by one.
Substract the value of the angle x to the value of this angle. The value is normalized after.
Divides the value of this angle with the value of angle x. The value is normalized after.
angle & angle::operator= | ( | const scalar_unit & | x | ) |
Assignment operator. The value of the angle is set to the value of the scalar_unit x, only if the scalar_unit has empty dimensions.
Definition at line 155 of file angle.cpp.
Assignment operator. An initialization string is used to set the value, which contains the character 00B0 or the character 00BA to represent degrees.
Assignment operator. The value is copied from the float.
Sets the value to the value of some numeric type, casting it to a float first, and normalizing the value after that.
Powers the value of this angle with the value of angle x. The value is normalized after.
scalar_unit angle::to_scalar_unit | ( | ) | const |
Creates a scalar_unit with the same value and degree dimensions.
Definition at line 256 of file angle.cpp.
|
protected |