3#include "../util/types.hpp"
5#include "boost/algorithm/string.hpp"
6#include "unicode/unistr.h"
7#include "unicode/uchar.h"
125 cerr <<
"An angle cannot be initialized with dimensions" <<
endl;
138 value = std::move(x.get_value());
164 cerr <<
"An angle cannot be initialized with dimensions" <<
endl;
282 while (
value >= 360.0f)
287 else if (
value < 0.0f)
393 if(x == y
or (x + 180.0f) == y)
405 float difference = std::abs((x - y).get_value());
551 return !(x == init_angle);
562 return !(init_angle == x);
567 ostringstream output;
574 ostringstream output;
582 ostringstream output;
590 return os << to_string(x);
istream & operator>>(istream &is, scifir::angle &x)
Initializes an angle with an initialization string obtained from an input stream.
bool operator<(const scifir::angle &x, const scifir::angle &y)
Checks if the value of angle x is lower than the value of angle y.
bool operator!=(const scifir::angle &x, const scifir::angle &y)
Checks if two angles have not equal value.
bool operator==(const scifir::angle &x, const scifir::angle &y)
Checks if two angles have equal value.
bool operator>(const scifir::angle &x, const scifir::angle &y)
Checks if the value of angle x is greather than the value of angle y.
ostream & operator<<(ostream &os, const scifir::angle &x)
Sends the string representation of angle x to an output stream.
bool operator>=(const scifir::angle &x, const scifir::angle &y)
Checks if the value of angle x is equal or greather than the value of angle y.
bool operator<=(const scifir::angle &x, const scifir::angle &y)
Checks if the value of angle x is lower or equal than the value of angle y.
string operator+(const string &x, const scifir::angle &y)
Concatenates the string x with the string representation of angle y into a new string.
void operator+=(string &x, const scifir::angle &y)
Concatenates to string x the string representation of angle y.
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
angle & operator--()
Decrements the value by one.
void initialize_from_string(string init_angle)
Internal function. Sets the value of the angle to a new value using the initialization string of angl...
const float & get_value() const
Gets the value of the angle, in degrees.
void operator^=(const angle &x)
Powers the value of this angle with the value of angle x. The value is normalized after.
scalar_unit to_scalar_unit() const
Creates a scalar_unit with the same value and degree dimensions.
float value
Value of the angle. It is stored in degrees.
type
Represents an type of angle, which can be a degree or a radian. The value of the angle inside the ang...
@ DEGREE
The angle is in DEGREE. A degree is defined as a 1/360 part of a circle. The entire circle correspond...
@ RADIAN
The angle is in RADIAN. A radian is defined as the length of the perimeter of the circle that conform...
angle operator+(const angle &x) const
Creates a new angle as the sum of other two.
void operator/=(const angle &x)
Divides the value of this angle with the value of angle x. The value is normalized after.
angle & operator++()
Increments the value by one.
angle operator-(const angle &x) const
Creates a new angle as the substraction of this angle and another angle x.
void operator-=(const angle &x)
Substract the value of the angle x to the value of this angle. The value is normalized after.
angle & operator=(const angle &x)
Copy assignment of angle. The value is copied to the value of 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.
float get_radian() const
Gets the value of the angle in radians.
void invert()
Inverts the angle to the opposite direction in a 2D plane, which is to add 180 degrees....
angle()
Default constructor of angle. The value is set to 0.
angle operator/(const angle &x) const
Creates a new angle as the division of this angle and another angle x.
string display(int number_of_decimals=2) const
Creates an string from the angle, with the value and the degrees symbol.
void normalize_value()
Internal function. Normalizes the value, which means to maintain the same angle within 0 and 360....
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 by powering the angle class with the value of another angle x.
void operator*=(const angle &x)
Multiplies the value of this angle with the value of angle x. The value is normalized after.
Class that represents dimensions of the SI system of units. Each dimension sizes 6 bytes,...
@ NUMERATOR
The dimension is at the numerator.
@ DEGREE
Degree, plural degrees. Dimension of angle. Symbol θ.
@ NONE
There is no prefix. Then, the dimension is not increased or decreased by some factor.
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
bool has_empty_dimensions() const
Checks if there aren't base dimensions.
const float & get_value() const
Read-only getter of the value.
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
angle sqrt_nth(const angle &x, int index)
Calculates the nth root of the angle x and returns that new angle.
angle asin(float x)
Calculates the asin of some value x and returns the result as angle in degrees.
float cos(const angle &x)
Calculates the cos of angle x. It uses the cos() function of the standard library of C++,...
bool orthogonal(const angle &x, const angle &y)
Checks if two angles in a 2D correspond to orthogonal lines (or orthogonal vectors).
float tanh(const angle &x)
Calculates the tanh of angle x. It uses the tanh() function of the standard library of C++,...
float radian_to_degree(float x)
Converts a radian to degree.
float sinh(const angle &x)
Calculates the sinh of angle x. It uses the sinh() function of the standard library of C++,...
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
angle atan2(float y, float x)
angle atan(float x)
Calculates the atan of some value x and returns the result as angle in degrees.
string display_float(const float &value, int number_of_decimals)
float cosh(const angle &x)
Calculates the cosh of angle x. It uses the cosh() function of the standard library of C++,...
angle acosh(float x)
Calculates the acosh of some value x and returns the result as angle in degrees.
angle asinh(float x)
Calculates the asinh of some value x and returns the result as angle in degrees.
angle atanh(float x)
Calculates the atanh of some value x and returns the result as angle in degrees.
angle acos(float x)
Calculates the acos of some value x and returns the result as angle in degrees.
float sin(const angle &x)
Calculates the sin of angle x. It uses the sin() function of the standard library of C++,...
float turn_to_degree(float x)
angle sqrt(const angle &x)
Calculates the square root of the angle x and returns that new angle.
bool parallel(const angle &x, const angle &y)
Checks if two angles in a 2D correspond to parallel lines (or parallel vectors).
float gradian_to_degree(float x)
float tan(const angle &x)
Calculates the tan of angle x. It uses the tan() function of the standard library of C++,...
bool is_angle(const string &init_angle)
Checks if some string is an initialization string of an angle.