3#include "../coordinates/coordinates_3d.hpp"
4#include "../util/types.hpp"
19 vector_unit_3d::vector_unit_3d(
float new_value,
dimension::type new_dimension,
prefix::type new_prefix,
float new_theta,
float new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
22 vector_unit_3d::vector_unit_3d(
float new_value,
dimension::type new_dimension,
prefix::type new_prefix,
const angle&
new_theta,
const angle&
new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
25 vector_unit_3d::vector_unit_3d(
double new_value,
dimension::type new_dimension,
prefix::type new_prefix,
float new_theta,
float new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
28 vector_unit_3d::vector_unit_3d(
double new_value,
dimension::type new_dimension,
prefix::type new_prefix,
const angle&
new_theta,
const angle&
new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
31 vector_unit_3d::vector_unit_3d(
long double new_value,
dimension::type new_dimension,
prefix::type new_prefix,
float new_theta,
float new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
34 vector_unit_3d::vector_unit_3d(
long double new_value,
dimension::type new_dimension,
prefix::type new_prefix,
const angle&
new_theta,
const angle&
new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
37 vector_unit_3d::vector_unit_3d(
int new_value,
dimension::type new_dimension,
prefix::type new_prefix,
float new_theta,
float new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
40 vector_unit_3d::vector_unit_3d(
int new_value,
dimension::type new_dimension,
prefix::type new_prefix,
const angle&
new_theta,
const angle&
new_phi,
dimension::position new_position) :
scalar_unit(
new_value,
new_dimension,
new_prefix,
new_position),theta(
new_theta),phi(
new_phi)
119 theta = std::move(x.theta);
120 phi = std::move(x.phi);
302 cerr <<
"Cannot sum vectors of different dimensions" <<
endl;
315 cerr <<
"Cannot substract vectors of different dimensions" <<
endl;
379 cerr <<
"Cannot power with as exponent a unit with dimensions" <<
endl;
406 string to_string(
const vector_unit_3d& x)
408 return x.vectorial_display(2);
432 string to_string(
const vector_unit_3d& x)
434 return x.vectorial_display(2);
442 if (values.size() == 4)
552 return !(x == init_vector_3d);
563 return !(init_vector_3d == y);
568 ostringstream output;
575 ostringstream output;
583 ostringstream output;
591 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 3D. The vector is in spherical coordinates with a value and dimen...
void operator+=(const vector_unit_3d &x)
The vector_unit_3d is summed as vector, in spherical coordinates. The addition of vectors is used for...
void operator-=(vector_unit_3d x)
The vector_unit_3d is substracted as vector, in spherical coordinates. The substraction of vectors is...
vector_unit_3d 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 invert()
Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to ...
scalar_unit y_projection() const
It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions,...
void initialize_from_string(string init_vector_3d)
Initializes the member-variables with the initialization string of vector_unit_3d init_vector_3d.
void point_to(direction::name x)
Theta is set to the direction specified in 3D. Possible values are LEFT, RIGHT, TOP,...
vector_unit_3d operator^(const scalar_unit &x) const
It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.
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 the angle theta and t...
scalar_unit x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions,...
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 and t...
vector_unit_3d & operator=(const vector_unit_3d &x)
Copy assignment. The member-variables are copied from the vector_unit_3d x.
vector_unit_3d()
Default constructor. The value is set to 0, the dimensions are empty and theta and phi are 0.
angle theta
Angle theta of the vector in 3D space, in spherical coordinates. As all angles of scifir-units,...
vector_unit_3d operator-(vector_unit_3d x) const
Substraction of vectors in 3D. It creates a new vector as the difference of the other two.
bool operator==(vector_unit_3d x) const
Comparison operator. Two vector_unit_3d are equal if their value, dimensions, theta and phi are the s...
vector_unit_3d operator+(const vector_unit_3d &x) const
Addition of vectors in 3D. It creates a new vector as the addition of the other two.
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 and t...
vector_unit_3d operator*(const scalar_unit &x) const
It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
angle phi
Angle phi of the vector in 3D space, in spherical coordinates. As all angles of scifir-units,...
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...
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.
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.
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.
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_3d &x, const string &init_vector_3d)
Returns true if x is equal to the vector_unit_3d initialized with the string being compared....
scifir::vector_unit_3d operator*(const scifir::scalar_unit &x, const scifir::vector_unit_3d &y)
It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
istream & operator>>(istream &is, scifir::vector_unit_3d &x)
Allows that an istream initializes by string a vector_unit_3d x.
ostream & operator<<(ostream &os, const scifir::vector_unit_3d &x)
Adds the string representation of the vector_unit_3d x to an output stream os.
bool operator!=(const scifir::vector_unit_3d &x, const scifir::vector_unit_3d &y)
Comparison operator. Two vector_unit_3d are not equal if their value, dimensions, theta or phi are di...
string operator+(const string &x, const scifir::vector_unit_3d &y)
Creates a new string as the concatenation of the string x with the representation string of the vecto...
void operator+=(string &x, const scifir::vector_unit_3d &y)
Concatenates the string representation of the vector_unit_3d y to the string x.