3#include "../coordinates/coordinates_2d.hpp"
4#include "../util/types.hpp"
6#include "boost/algorithm/string.hpp"
120 theta = std::move(x.theta);
202 cerr <<
"Cannot sum vectors of different dimensions" <<
endl;
215 cerr <<
"Cannot substract vectors of different dimensions" <<
endl;
275 cerr <<
"Cannot power with as exponent a unit with dimensions" <<
endl;
302 string to_string(
const vector_unit_2d& x)
304 return x.vectorial_display(2);
328 string to_string(
const vector_unit_2d& x)
330 return x.vectorial_display(2);
338 if (values.size() == 3)
410 return !(x == init_vector_2d);
421 return !(init_vector_2d == x);
426 ostringstream output;
433 ostringstream output;
441 ostringstream output;
449 return os << to_string(x);
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
const float & get_value() const
Gets the value of the angle, in degrees.
position
Represents the position of the dimension, which can be at the numerator or at the denominator....
type
Represents a dimension of the SI system of units. All the dimensions of the SI system of units are su...
type
Represents a prefix of the SI system of units. All the prefixes of the SI system of units are support...
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.
scalar_unit & operator=(const scalar_unit &x)
Copy assignment, it assigns a copy of the scalar_unit.
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
bool has_dimensions(const string &init_dimensions) const
Checks if the basic dimensions are the same as the initialization string of dimensions.
string display(int number_of_decimals=2, bool with_brackets=false, bool use_close_prefix=false) const
Generates a string representation of the scalar_unit, with the value and the dimensions....
float value
Value of the scalar_unit. It changes automatically when the dimensions change.
void change_dimensions(const string &init_dimensions)
Changes the dimensions to the dimensions specified by the initialization string of dimensions.
void initialize_from_string(string init_scalar, const vector< dimension > &real_dimensions)
Internal function. It sets the value and the dimensions of the scalar_unit to the value and dimension...
string custom_display(const string &init_dimensions, int number_of_decimals=2, bool with_brackets=false) const
Generates a string representation of the scalar_unit, with the dimensions changed to any set of dimen...
string base_display(int number_of_decimals=2, bool with_brackets=false, bool use_close_prefix=false) const
Generates a string representation of the scalar_unit, with its dimensions converted to their base cou...
const float & get_value() const
Read-only getter of the value.
scalar_unit operator^(const scalar_unit &x) const
Power operator, it powers a scalar_unit class with another, if that second scalar_unit class,...
Class that creates a vector unit in 2D. The vector is in polar coordinates with a value and dimension...
angle theta
Angle of the vector in 2D space, in polar coordinates. As all angles of scifir-units,...
scalar_unit y_projection() const
It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions,...
vector_unit_2d operator+(const vector_unit_2d &x) const
Addition of vectors in 2D. It creates a new vector as the addition of the other two.
string vectorial_custom_display(const string &init_dimensions, int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also the angle theta....
string vectorial_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also the angle theta.
void initialize_from_string(string init_vector_2d)
Initializes the member-variables with the initialization string of vector_unit_2d init_vector_2d.
void operator-=(vector_unit_2d x)
The vector_unit_2d is substracted as vector, in polar coordinates. The substraction of vectors is use...
void point_to(direction::name x)
Theta is set to the direction specified in 2D. Possible values are LEFT, RIGHT, TOP,...
void operator+=(const vector_unit_2d &x)
The vector_unit_2d is summed as vector, in polar coordinates. The addition of vectors is used for the...
vector_unit_2d operator*(const scalar_unit &x) const
It creates a new vector_unit_2d scaling a vector_unit_2d by the scalar_unit x.
string vectorial_base_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also the angle theta....
void invert()
Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to ...
vector_unit_2d & operator=(const vector_unit_2d &x)
Copy assignment. The member-variables are copied from the vector_unit_2d x.
vector_unit_2d operator-(vector_unit_2d x) const
Substraction of vectors in 2D. It creates a new vector as the difference of the other two.
bool operator==(vector_unit_2d x) const
Comparison operator. Two vector_unit_2d are equal if their value, dimensions and theta are the same.
scalar_unit x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions,...
vector_unit_2d()
Default constructor. The value is set to 0, the dimensions are empty and theta is 0.
vector_unit_2d operator^(const scalar_unit &x) const
It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.
vector_unit_2d operator/(const scalar_unit &x) const
It creates a new vector_unit_2d scaling a vector_unit_2d by the inverse of the scalar_unit x.
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
angle angle_between(const vector_unit_2d &x, const vector_unit_2d &y)
Returns the angle between two vectors x and y inside a 2D space.
angle sqrt_nth(const angle &x, int index)
Calculates the nth root of the angle x and returns that new angle.
bool same_direction(const vector_unit_2d &x, const vector_unit_2d &y)
Checks if two vectors x and y have the same direction.
vector< dimension > divide_dimensions(vector< dimension > x, const vector< dimension > &y, long double &value)
Divides the first vector of dimensions with the other. The result is normalized after,...
angle cartesian_2d_to_polar_theta(const scalar_unit &x, scalar_unit y)
bool orthogonal(const angle &x, const angle &y)
Checks if two angles in a 2D correspond to orthogonal lines (or orthogonal vectors).
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)
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit y)
string display_float(const float &value, int number_of_decimals)
scalar_unit dot_product(const vector_unit_2d &x, const vector_unit_2d &y)
Creates a scalar_unit as the dot product of the two vectors x and y.
vector< dimension > multiply_dimensions(const vector< dimension > &x, const vector< dimension > &y)
Multiplies two vectors of dimensions. The result is normalized after, which means that equal dimensio...
scalar_unit norm(const vector_unit_2d &x)
It returns the value of the vector in polar coordinates, p.
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).
scifir::vector_unit_2d operator*(const scifir::scalar_unit &x, const scifir::vector_unit_2d &y)
It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
string operator+(const string &x, const scifir::vector_unit_2d &y)
Creates a new string as the concatenation of the string x with the representation string of the vecto...
bool operator==(const scifir::vector_unit_2d &x, const string &init_vector_2d)
Returns true if x is equal to the vector_unit_2d initialized with the string being compared....
istream & operator>>(istream &is, scifir::vector_unit_2d &x)
Allows that an istream initializes by string a vector_unit_2d x.
void operator+=(string &x, const scifir::vector_unit_2d &y)
Concatenates the string representation of the vector_unit_2d y to the string x.
bool operator!=(const scifir::vector_unit_2d &x, const scifir::vector_unit_2d &y)
Comparison operator. Two vector_unit_2d are not equal if their value, dimensions or theta are differe...
ostream & operator<<(ostream &os, const scifir::vector_unit_2d &x)
Adds the string representation of the vector_unit_2d x to an output stream os.