3#include "../coordinates/coordinates_2d.hpp"
4#include "../coordinates/coordinates_3d.hpp"
215 angles = std::move(x.angles);
466 cerr <<
"Cannot sum vectors of different dimensions" <<
endl;
479 cerr <<
"Cannot substract vectors of different dimensions" <<
endl;
519 cerr <<
"Cannot sum vectors of different dimensions" <<
endl;
562 cerr <<
"Cannot sum vectors of different dimensions" <<
endl;
635 cerr <<
"Cannot power with as exponent a unit with dimensions" <<
endl;
771 if (values.size() > 2)
774 for (
unsigned int i = 2;
i < values.size();
i++)
864 for(
unsigned int i = 0;
i < x.
angles.size();
i++)
960 return !(x == init_vector_nd);
971 return !(init_vector_nd == x);
976 ostringstream output;
983 ostringstream output;
991 ostringstream output;
999 ostringstream angles_text;
1002 for(
const auto& x_angle : x.
angles)
1005 angles_text << x_angle;
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
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.
string display_dimensions() const
Generates an string of the dimensions of the scalar_unit, with the same format as the initialization ...
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.
scalar_unit()
Default constructor, the value is 0 and the dimensions are empty.
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 in ND, which means a variable number of dimensions. A vector_unit_nd can ...
vector_unit_nd()
Default constructor. The value is 0, the dimensions are empty and the angles are empty.
scalar_unit n_projection(int i) const
Returns the x projection, the y projection or the z projection, depending if i is 1 (it returns x),...
string vectorial_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also all the angles.
vector_unit_nd & operator=(const vector_unit_nd &x)
Copy assignment. The member-variables are copied from vector_unit_nd x.
void operator+=(const vector_unit_nd &x)
The vector_unit_nd is summed as vector in 2D, 3D, or more coordinates. It's summed as scalar in 1D.
int get_nd() const
Returns the number of dimensions.
bool is_nd(unsigned int i) const
Returns true if the vector is at the same number of dimensions as i.
bool operator==(vector_unit_nd x) const
Comparison operator. Two vector_unit_nd are equal if their value, dimensions and angles are the same.
vector< angle > angles
The angles. A total of one angle means the vector is in 2D in polar coordinates, two angles means it'...
string vectorial_base_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also all the angles....
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_nd operator+(const vector_unit_nd &x) const
Addition of vectors in 2D, 3D, or more coordinates. It's an addition of scalars in 1D....
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_nd operator/(const scalar_unit &x) const
It creates a new vector_unit_3d scaling a vector_unit_3d by the inverse of the scalar_unit x.
void operator-=(vector_unit_nd x)
The vector_unit_nd is substracted as vector in 2D, 3D, or more coordinates. It's substracted as scala...
vector_unit_nd operator-(vector_unit_nd x) const
Substraction of vectors in 2D, 3D, or more coordinates. It's a substraction of scalars in 1D....
void point_to(direction::name x)
The angles are set to the direction specified in 1D, 2D or 3D, depending on the current ND of vector_...
vector_unit_nd operator*(const scalar_unit &x) const
It creates a new vector_unit_nd scaling a vector_unit_nd by the scalar_unit x.
scalar_unit z_projection() const
It creates the z projection of the vector, returning it as a scalar_unit of the same dimensions,...
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 all the angles....
vector_unit_nd operator^(const scalar_unit &x) const
It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.
void initialize_from_string(string init_vector_nd)
Initializes the member-variables with the initialization string of vector_unit_nd init_vector_nd.
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_3d_to_spherical_theta(const scalar_unit &x, scalar_unit y, const scalar_unit &z)
Returns the theta coordinate of the spherical coordinates given the x, y and z of cartesian coordinat...
float cos(const angle &x)
Calculates the cos of angle x. It uses the cos() function of the standard library of C++,...
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.
bool same_nd(const vector_unit_nd &x, const vector_unit_nd &y)
Checks if two vectors have the same number of dimensions.
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit y)
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.
scalar_unit cartesian_3d_to_spherical_r(const scalar_unit &x, scalar_unit y, scalar_unit z)
Returns the r coordinate of the spherical coordinates given the x, y and z of cartesian coordinates i...
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...
angle cartesian_3d_to_spherical_phi(const scalar_unit &x, scalar_unit y, scalar_unit z)
Returns the phi coordinate of the spherical coordinates given the x, y and z of cartesian coordinates...
vector_unit_3d cross_product(const vector_unit_3d &x, const vector_unit_3d &y)
Creates a vector_unit_3d as the cross product of the two vectors x and y.
scalar_unit norm(const vector_unit_2d &x)
It returns the value of the vector in polar coordinates, p.
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++,...
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).
bool operator!=(const scifir::vector_unit_nd &x, const scifir::vector_unit_nd &y)
Comparison operator. Two vector_unit_nd are not equal if their value, dimensions or angles are differ...
istream & operator>>(istream &is, scifir::vector_unit_nd &x)
Allows that an istream initializes by string a vector_unit_nd x.
bool operator==(const scifir::vector_unit_nd &x, const string &init_vector_nd)
Returns true if x is equal to the vector_unit_nd initialized with the string being compared....
scifir::vector_unit_nd operator*(const scifir::scalar_unit &x, const scifir::vector_unit_nd &y)
It creates a new vector_unitn3d scaling a vector_unit_nd by the scalar_unit x.
ostream & operator<<(ostream &os, const scifir::vector_unit_nd &x)
Adds the string representation of the vector_unit_nd x to an output stream os.
void operator+=(string &x, const scifir::vector_unit_nd &y)
Concatenates the string representation of the vector_unit_nd y to the string x.
string operator+(const string &x, const scifir::vector_unit_nd &y)
Creates a new string as the concatenation of the string x with the representation string of the vecto...