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
|
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>
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_nd & | operator= (const vector_unit_nd &x) |
Copy assignment. The member-variables are copied from vector_unit_nd x. | |
vector_unit_nd & | operator= (vector_unit_nd &&x) |
Move assignment. The member-variables are moved from vector_unit_nd x. | |
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. | |
vector_unit_nd & | operator= (scalar_unit &&x) |
The value and the dimensions are moved from the scalar_unit x, the angles are not changed. | |
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. | |
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. | |
![]() | |
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_unit & | operator= (const scalar_unit &x) |
Copy assignment, it assigns a copy of the scalar_unit. | |
scalar_unit & | operator= (scalar_unit &&x) |
Move assignment, it moves the scalar_unit. | |
scalar_unit & | operator= (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_unit & | operator++ () |
Increment operator, it increases the value by one. | |
scalar_unit & | operator++ (int) |
Increment operator, it increases the value by one. | |
scalar_unit & | operator-- () |
Decrement operator, it decreases the value by one. | |
scalar_unit & | operator-- (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< dimension > | get_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 float & | get_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< angle > | 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. | |
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. | |
![]() | |
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 | |
![]() | |
vector< dimension > | dimensions |
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. | |
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.
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.
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.
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.
|
explicit |
Definition at line 19 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 27 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 30 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 38 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 41 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 49 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 52 of file vector_unit_nd.cpp.
|
explicit |
Definition at line 60 of file vector_unit_nd.cpp.
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.
|
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.
|
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.
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.
|
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.
|
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.
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.
|
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.
|
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.
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
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.
|
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.
|
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.
|
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.
|
inline |
Returns the number of dimensions.
Definition at line 571 of file vector_unit_nd.hpp.
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.
void scifir::vector_unit_nd::invert | ( | ) |
Definition at line 720 of file vector_unit_nd.cpp.
Returns true if the vector is at the same number of dimensions as i.
Definition at line 566 of file vector_unit_nd.hpp.
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.
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.
|
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.
It multiplies the numeric type x to the value. The angles are not changed.
Definition at line 547 of file vector_unit_nd.hpp.
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.
|
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.
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.
It sums the numeric type x to the value. The angles are not changed.
Definition at line 535 of file vector_unit_nd.hpp.
|
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.
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.
It substracts the numeric type x to the value. The angles are not changed.
Definition at line 541 of file vector_unit_nd.hpp.
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.
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.
|
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.
It divides the numeric type x to the value. The angles are not changed.
Definition at line 557 of file vector_unit_nd.hpp.
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.
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.
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.
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.
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.
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.
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.
|
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.
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.
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.
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.
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.
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.
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.
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.
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.