scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
scifir::vector_unit_nd Class Reference

Class that creates a vector in ND, which means a variable number of dimensions. A vector_unit_nd can change to be in 1D, in 2D or in 3D, but it cannot be in more than one dimension at the same time. The member-variables of vector_unit_nd are the value and the vector<dimension> of scalar_unit, and a vector<angle> angles. The number of angles is equal to the number of dimensions vector unit has - 1. In 1D vector_unit_nd doesn't has angles, in 2D vector_unit_nd is in polar coordinates and has 1 angle, and in 3D vector_unit_nd is in spherical coordinates and has 2 angles. All base and derived vectorial unit classes in ND inherit from vector_unit_nd, and add the suffix **_nd** in their name. Initialization string example: "1 N 20° 30° 40°". '°' is the Unicode Character U+00B0. More...

#include <vector_unit_nd.hpp>

Inheritance diagram for scifir::vector_unit_nd:
Inheritance graph
[legend]
Collaboration diagram for scifir::vector_unit_nd:
Collaboration graph
[legend]

Public Member Functions

 vector_unit_nd ()
 Default constructor. The value is 0, the dimensions are empty and the angles are empty.
 
 vector_unit_nd (const vector_unit_nd &x)
 Copy constructor. The member-variables are copied from vector_unit_nd x.
 
 vector_unit_nd (vector_unit_nd &&x)
 Move constructor. The member-variables are moved from vector_unit_nd x.
 
 vector_unit_nd (float new_value, dimension::type new_dimension, prefix::type new_prefix, vector< float > new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (float new_value, dimension::type new_dimension, prefix::type new_prefix, const vector< angle > &new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (double new_value, dimension::type new_dimension, prefix::type new_prefix, vector< float > new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (double new_value, dimension::type new_dimension, prefix::type new_prefix, const vector< angle > &new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (long double new_value, dimension::type new_dimension, prefix::type new_prefix, vector< float > new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (long double new_value, dimension::type new_dimension, prefix::type new_prefix, const vector< angle > &new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (int new_value, dimension::type new_dimension, prefix::type new_prefix, vector< float > new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (int new_value, dimension::type new_dimension, prefix::type new_prefix, const vector< angle > &new_angles, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_nd (float new_value, const string &init_dimensions)
 Constructor. The value is new_value and the dimensions are initialized with the initialization string of dimensions init_dimensions.
 
 vector_unit_nd (float new_value, const string &init_dimensions, const vector< float > &new_angles)
 Constructor. The value is new_value, the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (float new_value, const string &init_dimensions, const vector< angle > &new_angles)
 Constructor. The value is new_value, the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (double new_value, const string &init_dimensions)
 Constructor. The value is new_value (the double is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.
 
 vector_unit_nd (double new_value, const string &init_dimensions, const vector< float > &new_angles)
 Constructor. The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (double new_value, const string &init_dimensions, const vector< angle > &new_angles)
 Constructor. The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (long double new_value, const string &init_dimensions)
 Constructor. The value is new_value (the long double is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.
 
 vector_unit_nd (long double new_value, const string &init_dimensions, const vector< float > &new_angles)
 Constructor. The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (long double new_value, const string &init_dimensions, const vector< angle > &new_angles)
 Constructor. The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (int new_value, const string &init_dimensions)
 Constructor. The value is new_value (the int is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.
 
 vector_unit_nd (int new_value, const string &init_dimensions, const vector< float > &new_angles)
 Constructor. The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (int new_value, const string &init_dimensions, const vector< angle > &new_angles)
 Constructor. The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.
 
 vector_unit_nd (float new_value, const vector< dimension > &new_dimensions)
 The value is new_value and the dimensions are initialized with a vector of dimensions.
 
 vector_unit_nd (float new_value, const vector< dimension > &new_dimensions, const vector< float > &new_angles)
 The value is new_value, the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.
 
 vector_unit_nd (float new_value, const vector< dimension > &new_dimensions, const vector< angle > &new_angles)
 The value is new_value, the dimensions are initialized with a vector of dimensions and the angles are new_angles.
 
 vector_unit_nd (double new_value, const vector< dimension > &new_dimensions)
 The value is new_value (the double is casted to a float) and the dimensions are initialized with a vector of dimensions.
 
 vector_unit_nd (double new_value, const vector< dimension > &new_dimensions, const vector< float > &new_angles)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.
 
 vector_unit_nd (double new_value, const vector< dimension > &new_dimensions, const vector< angle > &new_angles)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.
 
 vector_unit_nd (long double new_value, const vector< dimension > &new_dimensions)
 The value is new_value (the long double is casted to a float) and the dimensions are initialized with a vector of dimensions.
 
 vector_unit_nd (long double new_value, const vector< dimension > &new_dimensions, const vector< float > &new_angles)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.
 
 vector_unit_nd (long double new_value, const vector< dimension > &new_dimensions, const vector< angle > &new_angles)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.
 
 vector_unit_nd (int new_value, const vector< dimension > &new_dimensions)
 The value is new_value (the int is casted to a float) and the dimensions are initialized with a vector of dimensions.
 
 vector_unit_nd (int new_value, const vector< dimension > &new_dimensions, const vector< float > &new_angles)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.
 
 vector_unit_nd (int new_value, const vector< dimension > &new_dimensions, const vector< angle > &new_angles)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.
 
 vector_unit_nd (const scalar_unit &x)
 The value and the dimensions are copied from the scalar_unit x, the angles are empty. The vector is in 1D.
 
 vector_unit_nd (const scalar_unit &x, const vector< float > &new_angles)
 The value and the dimensions are copied from the scalar_unit x, the angles are constructed with new_angles.
 
 vector_unit_nd (const scalar_unit &x, const vector< angle > &new_angles)
 The value and the dimensions are copied from the scalar_unit x, the angles are new_angles.
 
 vector_unit_nd (const string &init_scalar, const vector< float > &new_angles)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, the angles are constructed with new_angles.
 
 vector_unit_nd (const string &init_scalar, const vector< angle > &new_angles)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, the angles are new_angles.
 
 vector_unit_nd (const string &init_vector_nd)
 The value, the dimensions and all the angles are initialized from the initialization string of vector_unit_nd init_vector_nd.
 
vector_unit_ndoperator= (const vector_unit_nd &x)
 Copy assignment. The member-variables are copied from vector_unit_nd x.
 
vector_unit_ndoperator= (vector_unit_nd &&x)
 Move assignment. The member-variables are moved from vector_unit_nd x.
 
vector_unit_ndoperator= (const scalar_unit &x)
 The value and the dimensions are copied from the scalar_unit x, the angles are not changed.
 
vector_unit_ndoperator= (scalar_unit &&x)
 The value and the dimensions are moved from the scalar_unit x, the angles are not changed.
 
vector_unit_ndoperator= (const string &init_vector_nd)
 The value, the dimensions and the angles are set from the initialization string init_vector_nd.
 
bool operator== (vector_unit_nd x) const
 Comparison operator. Two vector_unit_nd are equal if their value, dimensions and angles are the same.
 
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_unit_nd. The possible values are LEFT, RIGHT, TOP, BOTTOM, LEFT_TOP, RIGHT_TOP, RIGHT_BOTTOM, LEFT_BOTTOM, FRONT, BACK, LEFT_FRONT, RIGHT_FRONT, TOP_FRONT, BOTTOM_FRONT, LEFT_BACK, RIGHT_BACK, TOP_BACK, BOTTOM_BACK, LEFT_TOP_FRONT, RIGHT_TOP_FRONT, LEFT_BOTTOM_FRONT, RIGHT_BOTTOM_FRONT, LEFT_TOP_BACK, RIGHT_TOP_BACK, LEFT_BOTTOM_BACK, RIGHT_BOTTOM_BACK.
 
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.
 
void operator-= (vector_unit_nd x)
 The vector_unit_nd is substracted as vector in 2D, 3D, or more coordinates. It's substracted as scalar in 1D.
 
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. It creates a new vector as the addition of the other two.
 
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. It creates a new vector as the difference of the other two.
 
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.
 
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.
 
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.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd operator+ (T x) const
 It creates a new vector as the addition of the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd operator- (T x) const
 It creates a new vector as the substraction of the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd operator* (T x) const
 It creates a new vector as the multiplication of the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd operator/ (T x) const
 It creates a new vector as the division of the value with the numeric type x. The angles are not changed.
 
template<typename T , typename = typename enable_if<is_integer_number<T>::value>::type>
vector_unit_nd operator^ (T x) const
 It creates a new vector as the power of the value with the numeric type x. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator+= (T x)
 It sums the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator-= (T x)
 It substracts the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator*= (T x)
 It multiplies the numeric type x to the value. The angles are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator/= (T x)
 It divides the numeric type x to the value. The angles are not changed.
 
bool is_nd (unsigned int i) const
 Returns true if the vector is at the same number of dimensions as i.
 
int get_nd () const
 Returns the number of dimensions.
 
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), 2 (it returns y) or 3 (it returns z).
 
scalar_unit x_projection () const
 It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D the projection is the value, in 2D it's in polar coordinates and in 3D it's in spherical coordinates.
 
scalar_unit y_projection () const
 It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D this projection doesn't exist, in 2D it's in polar coordinates and in 3D it's in spherical coordinates.
 
scalar_unit z_projection () const
 It creates the z projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D this projection doesn't exist, in 2D it doesn't exist neither and in 3D it's in spherical coordinates.
 
void invert ()
 
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.
 
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. It displays the dimensions with its base 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. It displays the vector in the dimensions specified in the initialization string of dimensions init_dimensions.
 
- Public Member Functions inherited from scifir::scalar_unit
 scalar_unit ()
 Default constructor, the value is 0 and the dimensions are empty.
 
 scalar_unit (const scalar_unit &x)
 Copy constructor, copies the value and the dimensions.
 
 scalar_unit (scalar_unit &&x)
 Move constructor, moves the value and the dimensions.
 
 scalar_unit (float new_value, dimension::type new_dimension, prefix::type new_prefix, dimension::position new_position=dimension::NUMERATOR)
 
 scalar_unit (double new_value, dimension::type new_dimension, prefix::type new_prefix, dimension::position new_position=dimension::NUMERATOR)
 
 scalar_unit (long double new_value, dimension::type new_dimension, prefix::type new_prefix, dimension::position new_position=dimension::NUMERATOR)
 
 scalar_unit (int new_value, dimension::type new_dimension, prefix::type new_prefix, dimension::position new_position=dimension::NUMERATOR)
 
 scalar_unit (float new_value, const string &init_dimensions)
 Creates a new scalar_unit with the value and with the dimensions specified in the string.
 
 scalar_unit (double new_value, const string &init_dimensions)
 Creates a new scalar_unit, the double is casted to a float.
 
 scalar_unit (long double new_value, const string &init_dimensions)
 Creates a new scalar_unit, the long double is casted to a float.
 
 scalar_unit (int new_value, const string &init_dimensions)
 Creates a new scalar_unit, the int is casted to a float.
 
 scalar_unit (float new_value, const vector< dimension > &new_dimensions)
 Creates a new scalar_unit with the value given and copying the dimensions.
 
 scalar_unit (double new_value, const vector< dimension > &new_dimensions)
 Creates a new scalar_unit, the double is casted to a float, the dimensions are copied.
 
 scalar_unit (long double new_value, const vector< dimension > &new_dimensions)
 Creates a new scalar_unit, the long double is casted to a float, the dimensions are copied.
 
 scalar_unit (int new_value, const vector< dimension > &new_dimensions)
 Creates a new scalar_unit, the int is casted to a float, the dimensions are copied.
 
 scalar_unit (const string &init_scalar)
 Creates a new scalar_unit, the initialization string specifies both the value and the dimensions.
 
scalar_unitoperator= (const scalar_unit &x)
 Copy assignment, it assigns a copy of the scalar_unit.
 
scalar_unitoperator= (scalar_unit &&x)
 Move assignment, it moves the scalar_unit.
 
scalar_unitoperator= (const string &init_scalar)
 Assignment with an initialization string, the value and the dimensions are both specified.
 
 operator float () const
 Cast the scalar_unit to their float equivalent, it discards the dimensions and copies the value to a float.
 
bool operator== (scalar_unit x) const
 Comparison operator, two scalar_unit classes are considered equivalent if they have the same value given the same dimensions.
 
scalar_unit operator+ (scalar_unit x) const
 Addition operator, it sums two scalar_unit classes, their dimensions are changed to be equal first. If the basic dimensions are different, it returns an empty scalar_unit class.
 
scalar_unit operator- (scalar_unit x) const
 Substraction operator, it substracts one scalar_unit from the other, their dimensions are changed to be equal first. If the basic dimensions are different, it returns an empty scalar_unit class.
 
scalar_unit operator* (scalar_unit x) const
 Multiplication operator, it multiplies two scalar_unit classes, their dimensions are also multiplied.
 
scalar_unit operator/ (scalar_unit x) const
 Division operator, it divides one scalar_unit class with the other, their dimensions are also divided.
 
scalar_unit operator^ (const scalar_unit &x) const
 Power operator, it powers a scalar_unit class with another, if that second scalar_unit class, which is the exponent, as empty dimensions. If the exponent doesn't has empty dimensions it returns an empty scalar_unit class.
 
void operator+= (scalar_unit x)
 Addition operator, it adds a scalar_unit class to another, by converting their dimensions to be equal first. If their basic dimensions are different, it doesn't sums to the value.
 
void operator-= (scalar_unit x)
 Substraction operator, it substracts a scalar_unit class to another, by converting their dimensions to be equal first. If their basic dimensions are different, it doesn't substracts to the value.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scalar_unit operator+ (T y) const
 Addition operator, it sums the numeric type to the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scalar_unit operator- (T y) const
 Substraction operator, it substracts the numeric type to the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scalar_unit operator* (T y) const
 Multiplication operator, it multiplies the numeric type with the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scalar_unit operator/ (T y) const
 Division operator, it divides the value with the numeric type, independent of the dimensions.
 
template<typename T , typename = typename enable_if<is_integer_number<T>::value>::type>
scalar_unit operator^ (T y) const
 Power operator, it powers the value with the numeric type, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator+= (T y)
 Addition operator, it adds the numeric type to the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator-= (T y)
 Substraction operator, it substracts the numeric type to the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator*= (T y)
 Multiplication operator, it multiplies the numeric type to the value, independent of the dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void operator/= (T y)
 Division operator, it divides the numeric type to the value, independent of the dimensions.
 
scalar_unitoperator++ ()
 Increment operator, it increases the value by one.
 
scalar_unitoperator++ (int)
 Increment operator, it increases the value by one.
 
scalar_unitoperator-- ()
 Decrement operator, it decreases the value by one.
 
scalar_unitoperator-- (int)
 Decrement operator, it decreases the value by one.
 
void change_dimensions (const string &init_dimensions)
 Changes the dimensions to the dimensions specified by the initialization string of dimensions.
 
void change_dimensions (const scalar_unit &x)
 Changes the dimensions to the same dimensions of the scalar_unit.
 
bool has_dimensions (const string &init_dimensions) const
 Checks if the basic dimensions are the same as the initialization string of dimensions.
 
bool has_dimensions (const vector< dimension > &x_dimensions) const
 Checks if the basic dimensions are the same as some set of dimensions.
 
bool has_dimensions (const scalar_unit &x) const
 Checks if the basic dimensions are the same as other scalar_unit.
 
bool has_empty_dimensions () const
 Checks if there aren't base dimensions.
 
bool is_dimensionless () const
 Returns true if there aren't dimensions or if all dimensions are dimensionless.
 
bool has_simple_dimensions () const
 Returns true if there's only a simple dimension.
 
bool has_single_dimensions () const
 Returns true if there's only one dimension, which can be simple or composite.
 
bool has_composite_dimensions () const
 Returns true is there's more than one simple dimension.
 
string display_dimensions () const
 Generates an string of the dimensions of the scalar_unit, with the same format as the initialization string of dimensions.
 
dimension::type get_single_dimension_type () const
 Returns the dimension::type if there's only one dimension, returns dimension::NONE if there's more than one dimension or if the dimensions are empty.
 
vector< dimensionget_base_dimensions () const
 Generates a set of the base dimensions of the dimensions of the scalar_unit.
 
const vector< dimension > & get_dimensions () const
 Read-only getter of the dimensions.
 
const floatget_value () const
 Read-only getter of the value.
 
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. The dimensions can be enclosed by brackets, and the value can be set to have the closest prefix.
 
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 counterpart.
 
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 dimensions, specified by an initialization string of dimensions.
 
string to_latex (const string &init_dimensions, int number_of_decimals=2, bool with_brackets=false) const
 

Static Public Member Functions

static vector_unit_nd cartesian_2d (const string &init_dimensions, float new_x, float new_y)
 The dimensions are initialized from the initialization string of dimensions new_dimensions, the cartesian coordinates new_x and new_y are converted to polar coordinates and then set the value and theta.
 
static vector_unit_nd cartesian_3d (const string &init_dimensions, float new_x, float new_y, float new_z)
 The dimensions are initialized from the initialization string of dimensions new_dimensions, the cartesian coordinates new_x, new_y and new_z are converted to spherical coordinates and then set the value, theta and phi.
 
static vector_unit_nd cylindrical (const string &init_dimensions, float new_p, angle new_theta, float new_z)
 The dimensions are initialized from the initialization string of dimensions new_dimensions, the cylindrical coordinates new_p, new_theta and new_z are converted to spherical coordinates and then set the value, theta and phi.
 

Public Attributes

vector< angleangles
 The angles. A total of one angle means the vector is in 2D in polar coordinates, two angles means it's in 3D in spherical coordinates.
 

Protected Member Functions

void initialize_from_string (string init_vector_nd)
 Initializes the member-variables with the initialization string of vector_unit_nd init_vector_nd.
 
- Protected Member Functions inherited from scifir::scalar_unit
void add_dimension (const dimension &new_dimension)
 Internal function. It adds a dimension, changing the value according to the conversion factor of the added dimension and the prefix.
 
void remove_dimension (const dimension &old_dimension)
 Internal function. It removes a dimension, changing the value according to the conversion factor of the removed dimension and the prefix.
 
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 dimensions specified by the initialization string of scalar_unit.
 
void check_dimensions (const vector< dimension > &real_dimensions)
 

Additional Inherited Members

- Protected Attributes inherited from scifir::scalar_unit
vector< dimensiondimensions
 Dimensions of the scalar_unit. They can be simple dimensions, composite dimensions or special names.
 
float value
 Value of the scalar_unit. It changes automatically when the dimensions change.
 

Detailed Description

Class that creates a vector in ND, which means a variable number of dimensions. A vector_unit_nd can change to be in 1D, in 2D or in 3D, but it cannot be in more than one dimension at the same time. The member-variables of vector_unit_nd are the value and the vector<dimension> of scalar_unit, and a vector<angle> angles. The number of angles is equal to the number of dimensions vector unit has - 1. In 1D vector_unit_nd doesn't has angles, in 2D vector_unit_nd is in polar coordinates and has 1 angle, and in 3D vector_unit_nd is in spherical coordinates and has 2 angles. All base and derived vectorial unit classes in ND inherit from vector_unit_nd, and add the suffix **_nd** in their name. Initialization string example: "1 N 20° 30° 40°". '°' is the Unicode Character U+00B0.

Definition at line 409 of file vector_unit_nd.hpp.

Constructor & Destructor Documentation

◆ vector_unit_nd() [1/41]

vector_unit_nd::vector_unit_nd ( )

Default constructor. The value is 0, the dimensions are empty and the angles are empty.

Definition at line 10 of file vector_unit_nd.cpp.

11 {}
scalar_unit()
Default constructor, the value is 0 and the dimensions are empty.
vector< angle > angles
The angles. A total of one angle means the vector is in 2D in polar coordinates, two angles means it'...

◆ vector_unit_nd() [2/41]

vector_unit_nd::vector_unit_nd ( const vector_unit_nd x)

Copy constructor. The member-variables are copied from vector_unit_nd x.

Definition at line 13 of file vector_unit_nd.cpp.

13 : scalar_unit(x),angles(x.angles)
14 {}

◆ vector_unit_nd() [3/41]

vector_unit_nd::vector_unit_nd ( vector_unit_nd &&  x)

Move constructor. The member-variables are moved from vector_unit_nd x.

Definition at line 16 of file vector_unit_nd.cpp.

16 : scalar_unit(std::move(x)),angles(std::move(x.angles))
17 {}

◆ vector_unit_nd() [4/41]

scifir::vector_unit_nd::vector_unit_nd ( float  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
vector< float new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 19 of file vector_unit_nd.cpp.

19 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles()
20 {
21 for(const float& x_angle : new_angles)
22 {
23 angles.push_back(angle(x_angle));
24 }
25 }

◆ vector_unit_nd() [5/41]

scifir::vector_unit_nd::vector_unit_nd ( float  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const vector< angle > &  new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 27 of file vector_unit_nd.cpp.

27 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles(new_angles)
28 {}

◆ vector_unit_nd() [6/41]

scifir::vector_unit_nd::vector_unit_nd ( double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
vector< float new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 30 of file vector_unit_nd.cpp.

30 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles()
31 {
32 for(const float& x_angle : new_angles)
33 {
34 angles.push_back(angle(x_angle));
35 }
36 }

◆ vector_unit_nd() [7/41]

scifir::vector_unit_nd::vector_unit_nd ( double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const vector< angle > &  new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 38 of file vector_unit_nd.cpp.

38 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles(new_angles)
39 {}

◆ vector_unit_nd() [8/41]

scifir::vector_unit_nd::vector_unit_nd ( long double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
vector< float new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 41 of file vector_unit_nd.cpp.

41 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles()
42 {
43 for(const float& x_angle : new_angles)
44 {
45 angles.push_back(angle(x_angle));
46 }
47 }

◆ vector_unit_nd() [9/41]

scifir::vector_unit_nd::vector_unit_nd ( long double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const vector< angle > &  new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 49 of file vector_unit_nd.cpp.

49 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles(new_angles)
50 {}

◆ vector_unit_nd() [10/41]

scifir::vector_unit_nd::vector_unit_nd ( int  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
vector< float new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 52 of file vector_unit_nd.cpp.

52 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles()
53 {
54 for(const float& x_angle : new_angles)
55 {
56 angles.push_back(angle(x_angle));
57 }
58 }

◆ vector_unit_nd() [11/41]

scifir::vector_unit_nd::vector_unit_nd ( int  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const vector< angle > &  new_angles,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 60 of file vector_unit_nd.cpp.

60 : scalar_unit(new_value,new_dimension,new_prefix,new_position),angles(new_angles)
61 {}

◆ vector_unit_nd() [12/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const string init_dimensions 
)
explicit

Constructor. The value is new_value and the dimensions are initialized with the initialization string of dimensions init_dimensions.

Definition at line 63 of file vector_unit_nd.cpp.

63 : scalar_unit(new_value,init_dimensions),angles()
64 {}

◆ vector_unit_nd() [13/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const string init_dimensions,
const vector< float > &  new_angles 
)
explicit

Constructor. The value is new_value, the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 66 of file vector_unit_nd.cpp.

66 : scalar_unit(new_value,init_dimensions),angles()
67 {
68 for(const float& x_angle : new_angles)
69 {
70 angles.push_back(angle(x_angle));
71 }
72 }

◆ vector_unit_nd() [14/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const string init_dimensions,
const vector< angle > &  new_angles 
)
explicit

Constructor. The value is new_value, the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 74 of file vector_unit_nd.cpp.

74 : scalar_unit(new_value,init_dimensions),angles(new_angles)
75 {}

◆ vector_unit_nd() [15/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const string init_dimensions 
)
explicit

Constructor. The value is new_value (the double is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.

Definition at line 77 of file vector_unit_nd.cpp.

77 : scalar_unit(new_value,init_dimensions),angles()
78 {}

◆ vector_unit_nd() [16/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const string init_dimensions,
const vector< float > &  new_angles 
)
explicit

Constructor. The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 80 of file vector_unit_nd.cpp.

80 : scalar_unit(new_value,init_dimensions),angles()
81 {
82 for(const float& x_angle : new_angles)
83 {
84 angles.push_back(angle(x_angle));
85 }
86 }

◆ vector_unit_nd() [17/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const string init_dimensions,
const vector< angle > &  new_angles 
)
explicit

Constructor. The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 88 of file vector_unit_nd.cpp.

88 : scalar_unit(new_value,init_dimensions),angles(new_angles)
89 {}

◆ vector_unit_nd() [18/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const string init_dimensions 
)
explicit

Constructor. The value is new_value (the long double is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.

Definition at line 91 of file vector_unit_nd.cpp.

91 : scalar_unit(new_value,init_dimensions),angles()
92 {}

◆ vector_unit_nd() [19/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const string init_dimensions,
const vector< float > &  new_angles 
)
explicit

Constructor. The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 94 of file vector_unit_nd.cpp.

94 : scalar_unit(new_value,init_dimensions),angles()
95 {
96 for(const float& x_angle : new_angles)
97 {
98 angles.push_back(angle(x_angle));
99 }
100 }

◆ vector_unit_nd() [20/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const string init_dimensions,
const vector< angle > &  new_angles 
)
explicit

Constructor. The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 102 of file vector_unit_nd.cpp.

102 : scalar_unit(new_value,init_dimensions),angles(new_angles)
103 {}

◆ vector_unit_nd() [21/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const string init_dimensions 
)
explicit

Constructor. The value is new_value (the int is casted to a float) and the dimensions are initialized with the initialization string of dimensions init_dimensions.

Definition at line 105 of file vector_unit_nd.cpp.

105 : scalar_unit(new_value,init_dimensions),angles()
106 {}

◆ vector_unit_nd() [22/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const string init_dimensions,
const vector< float > &  new_angles 
)
explicit

Constructor. The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are constructed with new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 108 of file vector_unit_nd.cpp.

108 : scalar_unit(new_value,init_dimensions),angles()
109 {
110 for(const float& x_angle : new_angles)
111 {
112 angles.push_back(angle(x_angle));
113 }
114 }

◆ vector_unit_nd() [23/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const string init_dimensions,
const vector< angle > &  new_angles 
)
explicit

Constructor. The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions init_dimensions, the angles are new_angles. With 1 angle the vector will be in 2D, with 2 angles it will be in 3D.

Definition at line 116 of file vector_unit_nd.cpp.

116 : scalar_unit(new_value,init_dimensions),angles(new_angles)
117 {}

◆ vector_unit_nd() [24/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const vector< dimension > &  new_dimensions 
)
explicit

The value is new_value and the dimensions are initialized with a vector of dimensions.

Definition at line 119 of file vector_unit_nd.cpp.

119 : scalar_unit(new_value,new_dimensions),angles()
120 {}

◆ vector_unit_nd() [25/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const vector< dimension > &  new_dimensions,
const vector< float > &  new_angles 
)
explicit

The value is new_value, the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.

Definition at line 122 of file vector_unit_nd.cpp.

122 : scalar_unit(new_value,new_dimensions),angles()
123 {
124 for(const float& x_angle : new_angles)
125 {
126 angles.push_back(angle(x_angle));
127 }
128 }

◆ vector_unit_nd() [26/41]

vector_unit_nd::vector_unit_nd ( float  new_value,
const vector< dimension > &  new_dimensions,
const vector< angle > &  new_angles 
)
explicit

The value is new_value, the dimensions are initialized with a vector of dimensions and the angles are new_angles.

Definition at line 130 of file vector_unit_nd.cpp.

130 : scalar_unit(new_value,new_dimensions),angles(new_angles)
131 {}

◆ vector_unit_nd() [27/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const vector< dimension > &  new_dimensions 
)
explicit

The value is new_value (the double is casted to a float) and the dimensions are initialized with a vector of dimensions.

Definition at line 133 of file vector_unit_nd.cpp.

133 : scalar_unit(new_value,new_dimensions),angles()
134 {}

◆ vector_unit_nd() [28/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const vector< dimension > &  new_dimensions,
const vector< float > &  new_angles 
)
explicit

The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.

Definition at line 136 of file vector_unit_nd.cpp.

136 : scalar_unit(new_value,new_dimensions),angles()
137 {
138 for(const float& x_angle : new_angles)
139 {
140 angles.push_back(angle(x_angle));
141 }
142 }

◆ vector_unit_nd() [29/41]

vector_unit_nd::vector_unit_nd ( double  new_value,
const vector< dimension > &  new_dimensions,
const vector< angle > &  new_angles 
)
explicit

The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.

Definition at line 144 of file vector_unit_nd.cpp.

144 : scalar_unit(new_value,new_dimensions),angles(new_angles)
145 {}

◆ vector_unit_nd() [30/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const vector< dimension > &  new_dimensions 
)
explicit

The value is new_value (the long double is casted to a float) and the dimensions are initialized with a vector of dimensions.

Definition at line 147 of file vector_unit_nd.cpp.

147 : scalar_unit(new_value,new_dimensions),angles()
148 {}

◆ vector_unit_nd() [31/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const vector< dimension > &  new_dimensions,
const vector< float > &  new_angles 
)
explicit

The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.

Definition at line 150 of file vector_unit_nd.cpp.

150 : scalar_unit(new_value,new_dimensions),angles()
151 {
152 for(const float& x_angle : new_angles)
153 {
154 angles.push_back(angle(x_angle));
155 }
156 }

◆ vector_unit_nd() [32/41]

vector_unit_nd::vector_unit_nd ( long double  new_value,
const vector< dimension > &  new_dimensions,
const vector< angle > &  new_angles 
)
explicit

The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.

Definition at line 158 of file vector_unit_nd.cpp.

158 : scalar_unit(new_value,new_dimensions),angles(new_angles)
159 {}

◆ vector_unit_nd() [33/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const vector< dimension > &  new_dimensions 
)
explicit

The value is new_value (the int is casted to a float) and the dimensions are initialized with a vector of dimensions.

Definition at line 161 of file vector_unit_nd.cpp.

161 : scalar_unit(new_value,new_dimensions),angles()
162 {}

◆ vector_unit_nd() [34/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const vector< dimension > &  new_dimensions,
const vector< float > &  new_angles 
)
explicit

The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are constructed with new_angles.

Definition at line 164 of file vector_unit_nd.cpp.

164 : scalar_unit(new_value,new_dimensions),angles()
165 {
166 for(const float& x_angle : new_angles)
167 {
168 angles.push_back(angle(x_angle));
169 }
170 }

◆ vector_unit_nd() [35/41]

vector_unit_nd::vector_unit_nd ( int  new_value,
const vector< dimension > &  new_dimensions,
const vector< angle > &  new_angles 
)
explicit

The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions and the angles are new_angles.

Definition at line 172 of file vector_unit_nd.cpp.

172 : scalar_unit(new_value,new_dimensions),angles(new_angles)
173 {}

◆ vector_unit_nd() [36/41]

vector_unit_nd::vector_unit_nd ( const scalar_unit x)
explicit

The value and the dimensions are copied from the scalar_unit x, the angles are empty. The vector is in 1D.

Definition at line 175 of file vector_unit_nd.cpp.

175 : scalar_unit(x),angles()
176 {}

◆ vector_unit_nd() [37/41]

vector_unit_nd::vector_unit_nd ( const scalar_unit x,
const vector< float > &  new_angles 
)
explicit

The value and the dimensions are copied from the scalar_unit x, the angles are constructed with new_angles.

Definition at line 178 of file vector_unit_nd.cpp.

178 : scalar_unit(x),angles()
179 {
180 for(const float& x_angle : new_angles)
181 {
182 angles.push_back(angle(x_angle));
183 }
184 }

◆ vector_unit_nd() [38/41]

vector_unit_nd::vector_unit_nd ( const scalar_unit x,
const vector< angle > &  new_angles 
)
explicit

The value and the dimensions are copied from the scalar_unit x, the angles are new_angles.

Definition at line 186 of file vector_unit_nd.cpp.

186 : scalar_unit(x),angles(new_angles)
187 {}

◆ vector_unit_nd() [39/41]

vector_unit_nd::vector_unit_nd ( const string init_scalar,
const vector< float > &  new_angles 
)
explicit

The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, the angles are constructed with new_angles.

Definition at line 189 of file vector_unit_nd.cpp.

189 : scalar_unit(init_scalar),angles()
190 {
191 for(const float& x_angle : new_angles)
192 {
193 angles.push_back(angle(x_angle));
194 }
195 }

◆ vector_unit_nd() [40/41]

vector_unit_nd::vector_unit_nd ( const string init_scalar,
const vector< angle > &  new_angles 
)
explicit

The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, the angles are new_angles.

Definition at line 197 of file vector_unit_nd.cpp.

197 : scalar_unit(init_scalar),angles(new_angles)
198 {}

◆ vector_unit_nd() [41/41]

vector_unit_nd::vector_unit_nd ( const string init_vector_nd)
explicit

The value, the dimensions and all the angles are initialized from the initialization string of vector_unit_nd init_vector_nd.

Definition at line 200 of file vector_unit_nd.cpp.

201 {
203 }
vector_unit_nd()
Default constructor. The value is 0, the dimensions are empty and the angles are empty.
void initialize_from_string(string init_vector_nd)
Initializes the member-variables with the initialization string of vector_unit_nd init_vector_nd.

Member Function Documentation

◆ cartesian_2d()

vector_unit_nd vector_unit_nd::cartesian_2d ( const string init_dimensions,
float  new_x,
float  new_y 
)
inlinestatic

The dimensions are initialized from the initialization string of dimensions new_dimensions, the cartesian coordinates new_x and new_y are converted to polar coordinates and then set the value and theta.

Definition at line 454 of file vector_unit_nd.hpp.

455 {
456 float new_value = float(std::sqrt(std::pow(new_x,2) + std::pow(new_y,2)));
457 float new_theta = scifir::atan_degree(new_y / new_x);
458 return vector_unit_nd(new_value,init_dimensions, {angle(new_theta)});
459 }
float atan_degree(float x)
Calculates the atan receiving x in degrees. It uses the atan() function of the standard library of C+...
Definition angle.hpp:252

◆ cartesian_3d()

vector_unit_nd vector_unit_nd::cartesian_3d ( const string init_dimensions,
float  new_x,
float  new_y,
float  new_z 
)
inlinestatic

The dimensions are initialized from the initialization string of dimensions new_dimensions, the cartesian coordinates new_x, new_y and new_z are converted to spherical coordinates and then set the value, theta and phi.

Definition at line 461 of file vector_unit_nd.hpp.

462 {
463 float new_value = float(std::sqrt(std::pow(new_x,2) + std::pow(new_y,2) + std::pow(new_z,2)));
464 float new_theta = scifir::atan_degree(new_y / new_x);
465 float new_phi = scifir::acos_degree(new_z / new_value);
466 return vector_unit_nd(new_value,init_dimensions, {angle(new_theta), angle(new_phi)});
467 }
float acos_degree(float x)
Calculates the acos receiving x in degrees. It uses the acos() function of the standard library of C+...
Definition angle.hpp:247

◆ cylindrical()

vector_unit_nd vector_unit_nd::cylindrical ( const string init_dimensions,
float  new_p,
angle  new_theta,
float  new_z 
)
inlinestatic

The dimensions are initialized from the initialization string of dimensions new_dimensions, the cylindrical coordinates new_p, new_theta and new_z are converted to spherical coordinates and then set the value, theta and phi.

Definition at line 469 of file vector_unit_nd.hpp.

470 {
471 float new_value = float(std::sqrt(std::pow(new_p,2) + std::pow(new_z,2)));
472 float new_phi = scifir::atan_degree(new_p / new_z);
473 return vector_unit_nd(new_value,init_dimensions, {new_theta, angle(new_phi)});
474 }

◆ get_nd()

int vector_unit_nd::get_nd ( ) const
inline

Returns the number of dimensions.

Definition at line 571 of file vector_unit_nd.hpp.

572 {
573 return int(angles.size() + 1);
574 }

◆ initialize_from_string()

void vector_unit_nd::initialize_from_string ( string  init_vector_nd)
protected

Initializes the member-variables with the initialization string of vector_unit_nd init_vector_nd.

Definition at line 766 of file vector_unit_nd.cpp.

767 {
768 vector<string> values;
769 boost::split(values,init_vector_nd,boost::is_any_of(" "));
770 scalar_unit::initialize_from_string(values[0] + " " + values[1],vector<dimension>());
771 if (values.size() > 2)
772 {
773 angles.clear();
774 for (unsigned int i = 2; i < values.size(); i++)
775 {
776 angles.push_back(angle(values[i]));
777 }
778 }
779 }
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...

◆ invert()

void scifir::vector_unit_nd::invert ( )

Definition at line 720 of file vector_unit_nd.cpp.

721 {
722 if (is_nd(2))
723 {
724 angles[0].invert();
725 }
726 else if (is_nd(3))
727 {
728 angles[0].invert();
729 angles[1] = 180.0f - angles[1];
730 }
731 }
bool is_nd(unsigned int i) const
Returns true if the vector is at the same number of dimensions as i.

◆ is_nd()

bool vector_unit_nd::is_nd ( unsigned int  i) const
inline

Returns true if the vector is at the same number of dimensions as i.

Definition at line 566 of file vector_unit_nd.hpp.

567 {
568 return angles.size() == (i - 1);
569 }

◆ n_projection()

scalar_unit vector_unit_nd::n_projection ( int  i) const

Returns the x projection, the y projection or the z projection, depending if i is 1 (it returns x), 2 (it returns y) or 3 (it returns z).

Definition at line 640 of file vector_unit_nd.cpp.

641 {
642 if (i == 1)
643 {
644 return x_projection();
645 }
646 else if (i == 2)
647 {
648 return y_projection();
649 }
650 else if (i == 3)
651 {
652 return z_projection();
653 }
654 else
655 {
656 return scalar_unit();
657 }
658 }
scalar_unit x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions,...
scalar_unit y_projection() const
It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions,...
scalar_unit z_projection() const
It creates the z projection of the vector, returning it as a scalar_unit of the same dimensions,...

◆ operator*() [1/2]

vector_unit_nd 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.

Definition at line 567 of file vector_unit_nd.cpp.

568 {
569 long double new_value = scalar_unit::value * x.get_value();
570 vector<dimension> new_dimensions = multiply_dimensions(get_dimensions(), x.get_dimensions(),new_value);
571 if(is_nd(1))
572 {
573 return vector_unit_nd(float(new_value), new_dimensions);
574 }
575 else if(is_nd(2))
576 {
577 return vector_unit_nd(float(new_value), new_dimensions, {angles[0]});
578 }
579 else if(is_nd(3))
580 {
581 return vector_unit_nd(float(new_value), new_dimensions, {angles[0], angles[1]});
582 }
583 else
584 {
585 return vector_unit_nd(float(new_value), new_dimensions, angles);
586 }
587 }
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
float value
Value of the scalar_unit. It changes automatically when the dimensions change.
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...

◆ operator*() [2/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd vector_unit_nd::operator* ( T  x) const
inline

It creates a new vector as the multiplication of the numeric type x to the value. The angles are not changed.

Definition at line 513 of file vector_unit_nd.hpp.

514 {
515 vector_unit_nd y = *this;
516 y *= x;
517 return y;
518 }

◆ operator*=()

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void vector_unit_nd::operator*= ( T  x)
inline

It multiplies the numeric type x to the value. The angles are not changed.

Definition at line 547 of file vector_unit_nd.hpp.

548 {
549 scalar_unit::value *= std::abs(x);
550 if(x < 0)
551 {
552 invert();
553 }
554 }

◆ operator+() [1/2]

vector_unit_nd 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. It creates a new vector as the addition of the other two.

Definition at line 483 of file vector_unit_nd.cpp.

484 {
485 if(has_dimensions(x))
486 {
487 if(is_nd(1))
488 {
489 float new_value = scalar_unit::value + x.get_value();
490 return vector_unit_nd(new_value,get_dimensions());
491 }
492 else if(is_nd(2))
493 {
494 float new_x = float(x_projection() + x.x_projection());
495 float new_y = float(y_projection() + x.y_projection());
496 float new_value = cartesian_2d_to_polar_p(new_x, new_y);
497 vector<angle> new_angles = vector<angle>();
498 new_angles.push_back(cartesian_2d_to_polar_theta(new_x, new_y));
499 return vector_unit_nd(new_value,get_dimensions(),new_angles);
500 }
501 else if(is_nd(3))
502 {
503 float new_x = float(x_projection() + x.x_projection());
504 float new_y = float(y_projection() + x.y_projection());
505 float new_z = float(z_projection() + x.z_projection());
506 float new_value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
507 vector<angle> new_angles = vector<angle>();
508 new_angles.push_back(angle(cartesian_3d_to_spherical_theta(new_x, new_y, new_z)));
509 new_angles.push_back(angle(cartesian_3d_to_spherical_phi(new_x, new_y, new_z)));
510 return vector_unit_nd(new_value,get_dimensions(),new_angles);
511 }
512 else
513 {
514 return vector_unit_nd();
515 }
516 }
517 else
518 {
519 cerr << "Cannot sum vectors of different dimensions" << endl;
520 return vector_unit_nd();
521 }
522 }
bool has_dimensions(const string &init_dimensions) const
Checks if the basic dimensions are the same as the initialization string of dimensions.
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...
angle cartesian_2d_to_polar_theta(const scalar_unit &x, scalar_unit y)
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit 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...
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...

◆ operator+() [2/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd vector_unit_nd::operator+ ( T  x) const
inline

It creates a new vector as the addition of the numeric type x to the value. The angles are not changed.

Definition at line 497 of file vector_unit_nd.hpp.

498 {
499 vector_unit_nd y = *this;
500 y += x;
501 return y;
502 }

◆ operator+=() [1/2]

void vector_unit_nd::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.

Definition at line 439 of file vector_unit_nd.cpp.

440 {
441 if(has_dimensions(x) and get_nd() == x.get_nd())
442 {
443 if(is_nd(1))
444 {
445 scalar_unit::value += x.get_value();
446 }
447 else if(is_nd(2))
448 {
449 float new_x = float(x_projection() + x.x_projection());
450 float new_y = float(y_projection() + x.y_projection());
452 angles[0] = cartesian_2d_to_polar_theta(new_x, new_y);
453 }
454 else if(is_nd(3))
455 {
456 float new_x = float(x_projection() + x.x_projection());
457 float new_y = float(y_projection() + x.y_projection());
458 float new_z = float(z_projection() + x.z_projection());
459 scalar_unit::value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
460 angles[0] = cartesian_3d_to_spherical_theta(new_x, new_y, new_z);
461 angles[1] = cartesian_3d_to_spherical_phi(new_x, new_y, new_z);
462 }
463 }
464 else
465 {
466 cerr << "Cannot sum vectors of different dimensions" << endl;
467 }
468 }
int get_nd() const
Returns the number of dimensions.

◆ operator+=() [2/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void vector_unit_nd::operator+= ( T  x)
inline

It sums the numeric type x to the value. The angles are not changed.

Definition at line 535 of file vector_unit_nd.hpp.

536 {
538 }

◆ operator-() [1/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd vector_unit_nd::operator- ( T  x) const
inline

It creates a new vector as the substraction of the numeric type x to the value. The angles are not changed.

Definition at line 505 of file vector_unit_nd.hpp.

506 {
507 vector_unit_nd y = *this;
508 y -= x;
509 return y;
510 }

◆ operator-() [2/2]

vector_unit_nd 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. It creates a new vector as the difference of the other two.

Definition at line 524 of file vector_unit_nd.cpp.

525 {
526 if(has_dimensions(x))
527 {
528 if(is_nd(1))
529 {
530 float new_value = scalar_unit::value - x.get_value();
531 return vector_unit_nd(new_value,get_dimensions());
532 }
533 else if(is_nd(2))
534 {
535 x.invert();
536 float new_x = float(x_projection() + x.x_projection());
537 float new_y = float(y_projection() + x.y_projection());
538 float new_value = cartesian_2d_to_polar_p(new_x, new_y);
539 vector<angle> new_angles = vector<angle>();
540 new_angles.push_back(cartesian_2d_to_polar_theta(new_x, new_y));
541 return vector_unit_nd(new_value,get_dimensions(),new_angles);
542 }
543 else if(is_nd(3))
544 {
545 x.invert();
546 float new_x = float(x_projection() + x.x_projection());
547 float new_y = float(y_projection() + x.y_projection());
548 float new_z = float(z_projection() + x.z_projection());
549 float new_value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
550 vector<angle> new_angles = vector<angle>();
551 new_angles.push_back(angle(cartesian_3d_to_spherical_theta(new_x, new_y, new_z)));
552 new_angles.push_back(angle(cartesian_3d_to_spherical_phi(new_x, new_y, new_z)));
553 return vector_unit_nd(new_value,get_dimensions(),new_angles);
554 }
555 else
556 {
557 return vector_unit_nd();
558 }
559 }
560 else
561 {
562 cerr << "Cannot sum vectors of different dimensions" << endl;
563 return vector_unit_nd();
564 }
565 }

◆ operator-=() [1/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void vector_unit_nd::operator-= ( T  x)
inline

It substracts the numeric type x to the value. The angles are not changed.

Definition at line 541 of file vector_unit_nd.hpp.

542 {
544 }

◆ operator-=() [2/2]

void vector_unit_nd::operator-= ( vector_unit_nd  x)

The vector_unit_nd is substracted as vector in 2D, 3D, or more coordinates. It's substracted as scalar in 1D.

Definition at line 470 of file vector_unit_nd.cpp.

471 {
472 if(has_dimensions(x))
473 {
474 x.invert();
475 *this += x;
476 }
477 else
478 {
479 cerr << "Cannot substract vectors of different dimensions" << endl;
480 }
481 }

◆ operator/() [1/2]

vector_unit_nd 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.

Definition at line 589 of file vector_unit_nd.cpp.

590 {
591 long double new_value = scalar_unit::value / x.get_value();
592 vector<dimension> new_dimensions = divide_dimensions(get_dimensions(), x.get_dimensions(),new_value);
593 if(is_nd(1))
594 {
595 return vector_unit_nd(float(new_value), new_dimensions);
596 }
597 else if(is_nd(2))
598 {
599 return vector_unit_nd(float(new_value), new_dimensions, {angles[0]});
600 }
601 else if(is_nd(3))
602 {
603 return vector_unit_nd(float(new_value), new_dimensions, {angles[0], angles[1]});
604 }
605 else
606 {
607 return vector_unit_nd(float(new_value), new_dimensions, angles);
608 }
609 }
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,...

◆ operator/() [2/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_nd vector_unit_nd::operator/ ( T  x) const
inline

It creates a new vector as the division of the value with the numeric type x. The angles are not changed.

Definition at line 521 of file vector_unit_nd.hpp.

522 {
523 vector_unit_nd y = *this;
524 y /= x;
525 return y;
526 }

◆ operator/=()

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
void vector_unit_nd::operator/= ( T  x)
inline

It divides the numeric type x to the value. The angles are not changed.

Definition at line 557 of file vector_unit_nd.hpp.

558 {
559 scalar_unit::value /= std::abs(x);
560 if(x < 0)
561 {
562 invert();
563 }
564 }

◆ operator=() [1/5]

vector_unit_nd & vector_unit_nd::operator= ( const scalar_unit x)

The value and the dimensions are copied from the scalar_unit x, the angles are not changed.

Definition at line 219 of file vector_unit_nd.cpp.

220 {
222 return *this;
223 }
scalar_unit & operator=(const scalar_unit &x)
Copy assignment, it assigns a copy of the scalar_unit.

◆ operator=() [2/5]

vector_unit_nd & vector_unit_nd::operator= ( const string init_vector_nd)

The value, the dimensions and the angles are set from the initialization string init_vector_nd.

Definition at line 231 of file vector_unit_nd.cpp.

232 {
234 return *this;
235 }

◆ operator=() [3/5]

vector_unit_nd & vector_unit_nd::operator= ( const vector_unit_nd x)

Copy assignment. The member-variables are copied from vector_unit_nd x.

Definition at line 205 of file vector_unit_nd.cpp.

206 {
208 angles = x.angles;
209 return *this;
210 }

◆ operator=() [4/5]

vector_unit_nd & vector_unit_nd::operator= ( scalar_unit &&  x)

The value and the dimensions are moved from the scalar_unit x, the angles are not changed.

Definition at line 225 of file vector_unit_nd.cpp.

226 {
227 scalar_unit::operator =(std::move(x));
228 return *this;
229 }

◆ operator=() [5/5]

vector_unit_nd & vector_unit_nd::operator= ( vector_unit_nd &&  x)

Move assignment. The member-variables are moved from vector_unit_nd x.

Definition at line 212 of file vector_unit_nd.cpp.

213 {
214 scalar_unit::operator =(std::move(x));
215 angles = std::move(x.angles);
216 return *this;
217 }

◆ operator==()

bool vector_unit_nd::operator== ( scifir::vector_unit_nd  x) const

Comparison operator. Two vector_unit_nd are equal if their value, dimensions and angles are the same.

Definition at line 237 of file vector_unit_nd.cpp.

238 {
239 x.change_dimensions(*this);
240 if(get_value() == x.get_value() and scifir::same_direction(*this,x) and has_dimensions(x))
241 {
242 return true;
243 }
244 else
245 {
246 return false;
247 }
248 }
void change_dimensions(const string &init_dimensions)
Changes the dimensions to the dimensions specified by the initialization string of dimensions.
const float & get_value() const
Read-only getter of the value.
bool same_direction(const vector_unit_2d &x, const vector_unit_2d &y)
Checks if two vectors x and y have the same direction.

◆ operator^() [1/2]

vector_unit_nd 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.

Definition at line 611 of file vector_unit_nd.cpp.

612 {
613 if(x.has_empty_dimensions())
614 {
616 if(is_nd(1))
617 {
618 return vector_unit_nd(new_unit);
619 }
620 else if(is_nd(2))
621 {
622 return vector_unit_nd(new_unit, {angles[0]});
623 }
624 else if(is_nd(3))
625 {
626 return vector_unit_nd(new_unit, {angles[0], angles[1]});
627 }
628 else
629 {
630 return vector_unit_nd(new_unit, angles);
631 }
632 }
633 else
634 {
635 cerr << "Cannot power with as exponent a unit with dimensions" << endl;
636 return vector_unit_nd();
637 }
638 }
scalar_unit operator^(const scalar_unit &x) const
Power operator, it powers a scalar_unit class with another, if that second scalar_unit class,...

◆ operator^() [2/2]

template<typename T , typename = typename enable_if<is_integer_number<T>::value>::type>
vector_unit_nd vector_unit_nd::operator^ ( T  x) const
inline

It creates a new vector as the power of the value with the numeric type x. The angles are not changed.

Definition at line 529 of file vector_unit_nd.hpp.

530 {
532 }
vector< dimension > power_dimensions(const vector< dimension > &x, int exponent)
Powers the dimensions by an exponent.

◆ point_to()

void vector_unit_nd::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_unit_nd. The possible values are LEFT, RIGHT, TOP, BOTTOM, LEFT_TOP, RIGHT_TOP, RIGHT_BOTTOM, LEFT_BOTTOM, FRONT, BACK, LEFT_FRONT, RIGHT_FRONT, TOP_FRONT, BOTTOM_FRONT, LEFT_BACK, RIGHT_BACK, TOP_BACK, BOTTOM_BACK, LEFT_TOP_FRONT, RIGHT_TOP_FRONT, LEFT_BOTTOM_FRONT, RIGHT_BOTTOM_FRONT, LEFT_TOP_BACK, RIGHT_TOP_BACK, LEFT_BOTTOM_BACK, RIGHT_BOTTOM_BACK.

Definition at line 250 of file vector_unit_nd.cpp.

251 {
252 if (is_nd(1))
253 {
254 if (x == direction::LEFT)
255 {
256 if (value > 0)
257 {
258 value *= -1;
259 }
260 }
261 else if(x == direction::RIGHT)
262 {
263 if (value < 0)
264 {
265 value *= -1;
266 }
267 }
268 }
269 else if (is_nd(2))
270 {
271 if (x == direction::LEFT)
272 {
273 angles[0] = 180.0f;
274 }
275 else if(x == direction::RIGHT)
276 {
277 angles[0] = 0.0f;
278 }
279 else if(x == direction::TOP)
280 {
281 angles[0] = 90.0f;
282 }
283 else if(x == direction::BOTTOM)
284 {
285 angles[0] = 270.0f;
286 }
287 else if(x == direction::LEFT_TOP)
288 {
289 angles[0] = 135.0f;
290 }
291 else if(x == direction::RIGHT_TOP)
292 {
293 angles[0] = 45.0f;
294 }
295 else if(x == direction::RIGHT_BOTTOM)
296 {
297 angles[0] = 315.0f;
298 }
299 else if(x == direction::LEFT_BOTTOM)
300 {
301 angles[0] = 225.0f;
302 }
303 }
304 else if (is_nd(3))
305 {
306 if (x == direction::LEFT)
307 {
308 angles[0] = 270.0f;
309 angles[1] = 90.0f;
310 }
311 else if(x == direction::RIGHT)
312 {
313 angles[0] = 90.0f;
314 angles[1] = 90.0f;
315 }
316 else if(x == direction::TOP)
317 {
318 angles[0] = 0.0f;
319 angles[1] = 0.0f;
320 }
321 else if(x == direction::BOTTOM)
322 {
323 angles[0] = 0.0f;
324 angles[1] = 180.0f;
325 }
326 else if(x == direction::LEFT_TOP)
327 {
328 angles[0] = 270.0f;
329 angles[1] = 45.0f;
330 }
331 else if(x == direction::RIGHT_TOP)
332 {
333 angles[0] = 90.0f;
334 angles[1] = 45.0f;
335 }
336 else if(x == direction::RIGHT_BOTTOM)
337 {
338 angles[0] = 90.0f;
339 angles[1] = 135.0f;
340 }
341 else if(x == direction::LEFT_BOTTOM)
342 {
343 angles[0] = 270.0f;
344 angles[1] = 135.0f;
345 }
346 else if(x == direction::FRONT)
347 {
348 angles[0] = 0.0f;
349 angles[1] = 90.0f;
350 }
351 else if(x == direction::BACK)
352 {
353 angles[0] = 180.0f;
354 angles[1] = 90.0f;
355 }
356 else if(x == direction::LEFT_FRONT)
357 {
358 angles[0] = 315.0f;
359 angles[1] = 90.0f;
360 }
361 else if(x == direction::RIGHT_FRONT)
362 {
363 angles[0] = 45.0f;
364 angles[1] = 90.0f;
365 }
366 else if(x == direction::TOP_FRONT)
367 {
368 angles[0] = 0.0f;
369 angles[1] = 45.0f;
370 }
371 else if(x == direction::BOTTOM_FRONT)
372 {
373 angles[0] = 0.0f;
374 angles[1] = 135.0f;
375 }
376 else if(x == direction::LEFT_BACK)
377 {
378 angles[0] = 225.0f;
379 angles[1] = 90.0f;
380 }
381 else if(x == direction::RIGHT_BACK)
382 {
383 angles[0] = 135.0f;
384 angles[1] = 90.0f;
385 }
386 else if(x == direction::TOP_BACK)
387 {
388 angles[0] = 180.0f;
389 angles[1] = 45.0f;
390 }
391 else if(x == direction::BOTTOM_BACK)
392 {
393 angles[0] = 180.0f;
394 angles[1] = 135.0f;
395 }
396 else if(x == direction::LEFT_TOP_FRONT)
397 {
398 angles[0] = 315.0f;
399 angles[1] = 45.0f;
400 }
401 else if(x == direction::RIGHT_TOP_FRONT)
402 {
403 angles[0] = 45.0f;
404 angles[1] = 45.0f;
405 }
406 else if(x == direction::LEFT_BOTTOM_FRONT)
407 {
408 angles[0] = 315.0f;
409 angles[1] = 135.0f;
410 }
412 {
413 angles[0] = 45.0f;
414 angles[1] = 135.0f;
415 }
416 else if(x == direction::LEFT_TOP_BACK)
417 {
418 angles[0] = 225.0f;
419 angles[1] = 45.0f;
420 }
421 else if(x == direction::RIGHT_TOP_BACK)
422 {
423 angles[0] = 135.0f;
424 angles[1] = 45.0f;
425 }
426 else if(x == direction::LEFT_BOTTOM_BACK)
427 {
428 angles[0] = 225.0f;
429 angles[1] = 135.0f;
430 }
431 else if(x == direction::RIGHT_BOTTOM_BACK)
432 {
433 angles[0] = 135.0f;
434 angles[1] = 135.0f;
435 }
436 }
437 }

◆ vectorial_base_display()

string vector_unit_nd::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. It displays the dimensions with its base dimensions.

Definition at line 744 of file vector_unit_nd.cpp.

745 {
746 ostringstream out;
747 out << base_display(number_of_decimals);
748 for (const angle& x_angle : angles)
749 {
750 out << " " << x_angle.display(number_of_decimals);
751 }
752 return out.str();
753 }
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...

◆ vectorial_custom_display()

string vector_unit_nd::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. It displays the vector in the dimensions specified in the initialization string of dimensions init_dimensions.

Definition at line 755 of file vector_unit_nd.cpp.

756 {
757 ostringstream out;
758 out << custom_display(init_dimensions,number_of_decimals);
759 for (const angle& x_angle : angles)
760 {
761 out << " " << x_angle.display(number_of_decimals);
762 }
763 return out.str();
764 }
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...

◆ vectorial_display()

string vector_unit_nd::vectorial_display ( int  number_of_decimals = 2) const

Displays the vector as the string representation of the scalar unit adding also all the angles.

Definition at line 733 of file vector_unit_nd.cpp.

734 {
735 ostringstream out;
736 out << display(number_of_decimals);
737 for (const angle& x_angle : angles)
738 {
739 out << " " << x_angle.display(number_of_decimals);
740 }
741 return out.str();
742 }
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....

◆ x_projection()

scalar_unit vector_unit_nd::x_projection ( ) const

It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D the projection is the value, in 2D it's in polar coordinates and in 3D it's in spherical coordinates.

Definition at line 660 of file vector_unit_nd.cpp.

661 {
662 if (is_nd(1))
663 {
665 }
666 else if (is_nd(2))
667 {
669 }
670 else if (is_nd(3))
671 {
673 }
674 else
675 {
676 return scalar_unit();
677 }
678 }
float cos(const angle &x)
Calculates the cos of angle x. It uses the cos() function of the standard library of C++,...
Definition angle.cpp:431
float sin(const angle &x)
Calculates the sin of angle x. It uses the sin() function of the standard library of C++,...
Definition angle.cpp:426

◆ y_projection()

scalar_unit vector_unit_nd::y_projection ( ) const

It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D this projection doesn't exist, in 2D it's in polar coordinates and in 3D it's in spherical coordinates.

Definition at line 680 of file vector_unit_nd.cpp.

681 {
682 if (is_nd(1))
683 {
684 return scalar_unit();
685 }
686 else if (is_nd(2))
687 {
689 }
690 else if (is_nd(3))
691 {
693 }
694 else
695 {
696 return scalar_unit();
697 }
698 }

◆ z_projection()

scalar_unit vector_unit_nd::z_projection ( ) const

It creates the z projection of the vector, returning it as a scalar_unit of the same dimensions, and the value corresponds to the projection. In 1D this projection doesn't exist, in 2D it doesn't exist neither and in 3D it's in spherical coordinates.

Definition at line 700 of file vector_unit_nd.cpp.

701 {
702 if (is_nd(1))
703 {
704 return scalar_unit();
705 }
706 else if (is_nd(2))
707 {
708 return scalar_unit();
709 }
710 else if (is_nd(3))
711 {
713 }
714 else
715 {
716 return scalar_unit();
717 }
718 }

Member Data Documentation

◆ angles

vector< angle > vector_unit_nd::angles

The angles. A total of one angle means the vector is in 2D in polar coordinates, two angles means it's in 3D in spherical coordinates.

Definition at line 587 of file vector_unit_nd.hpp.


The documentation for this class was generated from the following files: