1#ifndef SCIFIR_UNITS_MECA_NUMBER_ANGLE_HPP_INCLUDED
2#define SCIFIR_UNITS_MECA_NUMBER_ANGLE_HPP_INCLUDED
4#include "../units/constants.hpp"
5#include "../util/is_number.hpp"
6#include "../units/scalar_unit.hpp"
18 return x * 180.0f / std::numbers::pi_v<float>;
33 return x * std::numbers::pi_v<float> / 180.0f;
43 return x * 2 * std::numbers::pi_v<float>;
53 return x * 200.0f / std::numbers::pi_v<float>;
68 return x / (2.0f * std::numbers::pi_v<float>);
273template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
279template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
285template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
291template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
297template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
303template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
309template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
315template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
321template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
327template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
333template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
339template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
345template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
351template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
357template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
363template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
369template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
istream & operator>>(istream &is, scifir::angle &x)
Initializes an angle with an initialization string obtained from an input stream.
scifir::angle operator-(T x, const scifir::angle &y)
Creates a new angle as the substraction of the numeric type with the value of this angle.
scifir::angle operator^(T x, const scifir::angle &y)
Creates a new angle as the power of a numeric type with the value of this angle.
bool operator>=(T x, const scifir::angle &y)
Checks if the value of angle y is lower or equal than a numeric type x.
scifir::angle operator+(T x, const scifir::angle &y)
Creates a new angle as the sum of a numeric type with the value of this angle.
scifir::angle operator/(T x, const scifir::angle &y)
Creates a new angle as the division of the value of this angle with the numeric type.
ostream & operator<<(ostream &os, const scifir::angle &x)
Sends the string representation of angle x to an output stream.
bool operator<=(T x, const scifir::angle &y)
Checks if the value of angle y is equal or greather than a numeric type x.
bool operator>(T x, const scifir::angle &y)
Checks if the value of angle y is lower to a numeric type x.
scifir::angle operator*(T x, const scifir::angle &y)
Creates a new angle as the multiplication of a numeric type with the value of this angle.
bool operator<(T x, const scifir::angle &y)
Checks if the value of angle y is greather to a numeric type x.
bool operator!=(T x, const scifir::angle &y)
Checks if the value of angle y is not equal to a numeric type x.
bool operator==(T x, const scifir::angle &y)
Checks if the value of angle y is equal to a numeric type x.
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.
float get_degree() const
Gets the value of the angle in degrees.
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 allows to create scalar units, which are composed of a value (as a float) and dimensions....
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.
float atanh_degree(float x)
Calculates the atanh receiving x in degrees. It uses the atanh() function of the standard library of ...
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++,...
float degree_to_gradian(float x)
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++,...
float degree_to_turn(float x)
float gradian_to_radian(float x)
float atan_degree(float x)
Calculates the atan receiving x in degrees. It uses the atan() function of the standard library of C+...
float turn_to_radian(float x)
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)
float degree_to_radian(float x)
Converts a degree to a radian.
angle atan(float x)
Calculates the atan of some value x and returns the result as angle in degrees.
float acos_degree(float x)
Calculates the acos receiving x in degrees. It uses the acos() function of the standard library of C+...
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.
float turn_to_gradian(float x)
float acosh_degree(float x)
Calculates the acosh receiving x in degrees. It uses the acosh() function of the standard library of ...
float asin_degree(float x)
Calculates the asin receiving x in degrees. It uses the asin() function of the standard library of C+...
float radian_to_turn(float x)
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)
float asinh_degree(float x)
Calculates the asinh receiving x in degrees. It uses the asinh() function of the standard library of ...
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 radian_to_gradian(float x)
float gradian_to_turn(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.