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_3d Class Reference

Class that creates a vector unit in 3D. The vector is in spherical coordinates with a value and dimensions of the scalar_unit, and an angle theta and another angle phi for his direction. All base and derived vectorial unit classes in 3D inherit from vector_unit_3d, and add the suffix **_3d** in their name. Initialization string example: "1 N 20θ 30Φ". 'θ' is the Unicode Character U+03B8. 'Φ' is the Unicode Character U+03A6. More...

#include <vector_unit_3d.hpp>

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

Public Member Functions

 vector_unit_3d ()
 Default constructor. The value is set to 0, the dimensions are empty and theta and phi are 0.
 
 vector_unit_3d (const vector_unit_3d &x)
 Copy constructor. The member-variables are copied from vector_unit_3d x.
 
 vector_unit_3d (vector_unit_3d &&x)
 Move constructor. The member-variables are moved from vector_unit_3d x.
 
 vector_unit_3d (float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, const angle &new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, const angle &new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, const angle &new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, const angle &new_phi, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_3d (float new_value, const string &init_dimensions, float new_theta, float new_phi)
 The value is new_value, the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (float new_value, const string &init_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value, the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (double new_value, const string &init_dimensions, float new_theta, float new_phi)
 The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (double new_value, const string &init_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (long double new_value, const string &init_dimensions, float new_theta, float new_phi)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (long double new_value, const string &init_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (int new_value, const string &init_dimensions, float new_theta, float new_phi)
 The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (int new_value, const string &init_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (float new_value, const vector< dimension > &new_dimensions, float new_theta, float new_phi)
 The value is new_value, the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (float new_value, const vector< dimension > &new_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value, the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (double new_value, const vector< dimension > &new_dimensions, float new_theta, float new_phi)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (double new_value, const vector< dimension > &new_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (long double new_value, const vector< dimension > &new_dimensions, float new_theta, float new_phi)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (long double new_value, const vector< dimension > &new_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (int new_value, const vector< dimension > &new_dimensions, float new_theta, float new_phi)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (int new_value, const vector< dimension > &new_dimensions, const angle &new_theta, const angle &new_phi)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.
 
 vector_unit_3d (const scalar_unit &x, float new_theta, float new_phi)
 The value and the dimensions are copied from the scalar_unit x, theta is new_theta, phi is new_phi.
 
 vector_unit_3d (const scalar_unit &x, const angle &new_theta, const angle &new_phi)
 The value and the dimensions are copied from the scalar_unit x, theta is new_theta, phi is new_phi.
 
 vector_unit_3d (const string &init_scalar, float new_theta, float new_phi)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta, phi is new_phi.
 
 vector_unit_3d (const string &init_scalar, const angle &new_theta, const angle &new_phi)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta, phi is new_phi.
 
 vector_unit_3d (const string &init_vector_3d)
 The value, the dimensions, theta and phi are initialized from the initialization string of vector_unit_3d init_vector_3d.
 
vector_unit_3doperator= (const vector_unit_3d &x)
 Copy assignment. The member-variables are copied from the vector_unit_3d x.
 
vector_unit_3doperator= (vector_unit_3d &&x)
 Move assignment. The member-variables are moved from the vector_unit_3d x.
 
vector_unit_3doperator= (const scalar_unit &x)
 The value and the dimensions are copied from the scalar_unit x, theta and phi are not changed.
 
vector_unit_3doperator= (scalar_unit &&x)
 The value and the dimensions are moved from the scalar_unit x, theta and phi are not changed.
 
vector_unit_3doperator= (const string &init_vector_3d)
 The value, the dimensions, theta and phi are set from the initialization string init_vector_3d.
 
bool operator== (vector_unit_3d x) const
 Comparison operator. Two vector_unit_3d are equal if their value, dimensions, theta and phi are the same.
 
void point_to (direction::name x)
 Theta is set to the direction specified in 3D. 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_3d &x)
 The vector_unit_3d is summed as vector, in spherical coordinates. The addition of vectors is used for the calculation.
 
void operator-= (vector_unit_3d x)
 The vector_unit_3d is substracted as vector, in spherical coordinates. The substraction of vectors is used for the calculation.
 
vector_unit_3d operator+ (const vector_unit_3d &x) const
 Addition of vectors in 3D. It creates a new vector as the addition of the other two.
 
vector_unit_3d operator- (vector_unit_3d x) const
 Substraction of vectors in 3D. It creates a new vector as the difference of the other two.
 
vector_unit_3d operator* (const scalar_unit &x) const
 It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
 
vector_unit_3d operator/ (const scalar_unit &x) const
 It creates a new vector_unit_3d scaling a vector_unit_3d by the inverse of the scalar_unit x.
 
vector_unit_3d operator^ (const scalar_unit &x) const
 It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_3d operator+ (T x) const
 It creates a new vector as the addition of the numeric type x to the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_3d operator- (T x) const
 It creates a new vector as the substraction of the numeric type x to the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_3d operator* (T x) const
 It creates a new vector as the multiplication of the numeric type x to the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_3d operator/ (T x) const
 It creates a new vector as the division of the value with the numeric type x. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<is_integer_number<T>::value>::type>
vector_unit_3d operator^ (T x) const
 It creates a new vector as the power of the value with the numeric type x. Theta and phi 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. Theta and phi 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. Theta and phi 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. Theta and phi 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. Theta and phi are not changed.
 
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.
 
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.
 
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.
 
void invert ()
 Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to theta and calculating the new phi as "180 - phi".
 
string vectorial_display (int number_of_decimals=2) const
 Displays the vector as the string representation of the scalar unit adding also the angle theta and the angle phi.
 
string vectorial_base_display (int number_of_decimals=2) const
 Displays the vector as the string representation of the scalar unit adding also the angle theta and the angle phi. 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 the angle theta and the angle phi. 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_3d 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_3d 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

angle theta
 Angle theta of the vector in 3D space, in spherical coordinates. As all angles of scifir-units, it's stored in degrees.
 
angle phi
 Angle phi of the vector in 3D space, in spherical coordinates. As all angles of scifir-units, it's stored in degrees.
 

Protected Member Functions

void initialize_from_string (string init_vector_3d)
 Initializes the member-variables with the initialization string of vector_unit_3d init_vector_3d.
 
- 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 unit in 3D. The vector is in spherical coordinates with a value and dimensions of the scalar_unit, and an angle theta and another angle phi for his direction. All base and derived vectorial unit classes in 3D inherit from vector_unit_3d, and add the suffix **_3d** in their name. Initialization string example: "1 N 20θ 30Φ". 'θ' is the Unicode Character U+03B8. 'Φ' is the Unicode Character U+03A6.

Definition at line 302 of file vector_unit_3d.hpp.

Constructor & Destructor Documentation

◆ vector_unit_3d() [1/32]

vector_unit_3d::vector_unit_3d ( )

Default constructor. The value is set to 0, the dimensions are empty and theta and phi are 0.

Definition at line 10 of file vector_unit_3d.cpp.

10 : scalar_unit(),theta(),phi()
11 {}
scalar_unit()
Default constructor, the value is 0 and the dimensions are empty.
angle theta
Angle theta of the vector in 3D space, in spherical coordinates. As all angles of scifir-units,...
angle phi
Angle phi of the vector in 3D space, in spherical coordinates. As all angles of scifir-units,...

◆ vector_unit_3d() [2/32]

vector_unit_3d::vector_unit_3d ( const vector_unit_3d x)

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

Definition at line 13 of file vector_unit_3d.cpp.

13 : scalar_unit(x),theta(x.theta),phi(x.phi)
14 {}

◆ vector_unit_3d() [3/32]

vector_unit_3d::vector_unit_3d ( vector_unit_3d &&  x)

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

Definition at line 16 of file vector_unit_3d.cpp.

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

◆ vector_unit_3d() [4/32]

scifir::vector_unit_3d::vector_unit_3d ( float  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
float  new_theta,
float  new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 19 of file vector_unit_3d.cpp.

19 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
20 {}

◆ vector_unit_3d() [5/32]

scifir::vector_unit_3d::vector_unit_3d ( float  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const angle new_theta,
const angle new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 22 of file vector_unit_3d.cpp.

22 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
23 {}

◆ vector_unit_3d() [6/32]

scifir::vector_unit_3d::vector_unit_3d ( double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
float  new_theta,
float  new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 25 of file vector_unit_3d.cpp.

25 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
26 {}

◆ vector_unit_3d() [7/32]

scifir::vector_unit_3d::vector_unit_3d ( double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const angle new_theta,
const angle new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 28 of file vector_unit_3d.cpp.

28 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
29 {}

◆ vector_unit_3d() [8/32]

scifir::vector_unit_3d::vector_unit_3d ( long double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
float  new_theta,
float  new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 31 of file vector_unit_3d.cpp.

31 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
32 {}

◆ vector_unit_3d() [9/32]

scifir::vector_unit_3d::vector_unit_3d ( long double  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const angle new_theta,
const angle new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 34 of file vector_unit_3d.cpp.

34 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
35 {}

◆ vector_unit_3d() [10/32]

scifir::vector_unit_3d::vector_unit_3d ( int  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
float  new_theta,
float  new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 37 of file vector_unit_3d.cpp.

37 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
38 {}

◆ vector_unit_3d() [11/32]

scifir::vector_unit_3d::vector_unit_3d ( int  new_value,
dimension::type  new_dimension,
prefix::type  new_prefix,
const angle new_theta,
const angle new_phi,
dimension::position  new_position = dimension::NUMERATOR 
)
explicit

Definition at line 40 of file vector_unit_3d.cpp.

40 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta),phi(new_phi)
41 {}

◆ vector_unit_3d() [12/32]

vector_unit_3d::vector_unit_3d ( float  new_value,
const string init_dimensions,
float  new_theta,
float  new_phi 
)
explicit

The value is new_value, the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 43 of file vector_unit_3d.cpp.

43 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
44 {}

◆ vector_unit_3d() [13/32]

vector_unit_3d::vector_unit_3d ( float  new_value,
const string init_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

The value is new_value, the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 46 of file vector_unit_3d.cpp.

46 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
47 {}

◆ vector_unit_3d() [14/32]

vector_unit_3d::vector_unit_3d ( double  new_value,
const string init_dimensions,
float  new_theta,
float  new_phi 
)
explicit

The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 49 of file vector_unit_3d.cpp.

49 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
50 {}

◆ vector_unit_3d() [15/32]

vector_unit_3d::vector_unit_3d ( double  new_value,
const string init_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 52 of file vector_unit_3d.cpp.

52 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
53 {}

◆ vector_unit_3d() [16/32]

vector_unit_3d::vector_unit_3d ( long double  new_value,
const string init_dimensions,
float  new_theta,
float  new_phi 
)
explicit

The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 55 of file vector_unit_3d.cpp.

55 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
56 {}

◆ vector_unit_3d() [17/32]

vector_unit_3d::vector_unit_3d ( long double  new_value,
const string init_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 58 of file vector_unit_3d.cpp.

58 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
59 {}

◆ vector_unit_3d() [18/32]

vector_unit_3d::vector_unit_3d ( int  new_value,
const string init_dimensions,
float  new_theta,
float  new_phi 
)
explicit

The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 61 of file vector_unit_3d.cpp.

61 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
62 {}

◆ vector_unit_3d() [19/32]

vector_unit_3d::vector_unit_3d ( int  new_value,
const string init_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, theta is new_theta and phi is new_phi.

Definition at line 64 of file vector_unit_3d.cpp.

64 : scalar_unit(new_value,init_dimensions),theta(new_theta),phi(new_phi)
65 {}

◆ vector_unit_3d() [20/32]

vector_unit_3d::vector_unit_3d ( float  new_value,
const vector< dimension > &  new_dimensions,
float  new_theta,
float  new_phi 
)
explicit

The value is new_value, the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.

Definition at line 67 of file vector_unit_3d.cpp.

67 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
68 {}

◆ vector_unit_3d() [21/32]

vector_unit_3d::vector_unit_3d ( float  new_value,
const vector< dimension > &  new_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

The value is new_value, the dimensions are initialized with a vector of dimensions, theta is new_theta and phi is new_phi.

Definition at line 70 of file vector_unit_3d.cpp.

70 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
71 {}

◆ vector_unit_3d() [22/32]

vector_unit_3d::vector_unit_3d ( double  new_value,
const vector< dimension > &  new_dimensions,
float  new_theta,
float  new_phi 
)
explicit

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

Definition at line 73 of file vector_unit_3d.cpp.

73 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
74 {}

◆ vector_unit_3d() [23/32]

vector_unit_3d::vector_unit_3d ( double  new_value,
const vector< dimension > &  new_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

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

Definition at line 76 of file vector_unit_3d.cpp.

76 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
77 {}

◆ vector_unit_3d() [24/32]

vector_unit_3d::vector_unit_3d ( long double  new_value,
const vector< dimension > &  new_dimensions,
float  new_theta,
float  new_phi 
)
explicit

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

Definition at line 79 of file vector_unit_3d.cpp.

79 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
80 {}

◆ vector_unit_3d() [25/32]

vector_unit_3d::vector_unit_3d ( long double  new_value,
const vector< dimension > &  new_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

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

Definition at line 82 of file vector_unit_3d.cpp.

82 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
83 {}

◆ vector_unit_3d() [26/32]

vector_unit_3d::vector_unit_3d ( int  new_value,
const vector< dimension > &  new_dimensions,
float  new_theta,
float  new_phi 
)
explicit

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

Definition at line 85 of file vector_unit_3d.cpp.

85 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
86 {}

◆ vector_unit_3d() [27/32]

vector_unit_3d::vector_unit_3d ( int  new_value,
const vector< dimension > &  new_dimensions,
const angle new_theta,
const angle new_phi 
)
explicit

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

Definition at line 88 of file vector_unit_3d.cpp.

88 : scalar_unit(new_value,new_dimensions),theta(new_theta),phi(new_phi)
89 {}

◆ vector_unit_3d() [28/32]

vector_unit_3d::vector_unit_3d ( const scalar_unit x,
float  new_theta,
float  new_phi 
)
explicit

The value and the dimensions are copied from the scalar_unit x, theta is new_theta, phi is new_phi.

Definition at line 91 of file vector_unit_3d.cpp.

91 : scalar_unit(x),theta(new_theta),phi(new_phi)
92 {}

◆ vector_unit_3d() [29/32]

vector_unit_3d::vector_unit_3d ( const scalar_unit x,
const angle new_theta,
const angle new_phi 
)
explicit

The value and the dimensions are copied from the scalar_unit x, theta is new_theta, phi is new_phi.

Definition at line 94 of file vector_unit_3d.cpp.

94 : scalar_unit(x),theta(new_theta),phi(new_phi)
95 {}

◆ vector_unit_3d() [30/32]

vector_unit_3d::vector_unit_3d ( const string init_scalar,
float  new_theta,
float  new_phi 
)
explicit

The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta, phi is new_phi.

Definition at line 97 of file vector_unit_3d.cpp.

97 : scalar_unit(init_scalar),theta(new_theta),phi(new_phi)
98 {}

◆ vector_unit_3d() [31/32]

vector_unit_3d::vector_unit_3d ( const string init_scalar,
const angle new_theta,
const angle new_phi 
)
explicit

The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta, phi is new_phi.

Definition at line 100 of file vector_unit_3d.cpp.

100 : scalar_unit(init_scalar),theta(new_theta),phi(new_phi)
101 {}

◆ vector_unit_3d() [32/32]

vector_unit_3d::vector_unit_3d ( const string init_vector_3d)
explicit

The value, the dimensions, theta and phi are initialized from the initialization string of vector_unit_3d init_vector_3d.

Definition at line 103 of file vector_unit_3d.cpp.

104 {
106 }
void initialize_from_string(string init_vector_3d)
Initializes the member-variables with the initialization string of vector_unit_3d init_vector_3d.
vector_unit_3d()
Default constructor. The value is set to 0, the dimensions are empty and theta and phi are 0.

Member Function Documentation

◆ cartesian_3d()

vector_unit_3d vector_unit_3d::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 338 of file vector_unit_3d.hpp.

339 {
340 float new_value = float(std::sqrt(std::pow(new_x,2) + std::pow(new_y,2) + std::pow(new_z,2)));
341 float new_theta = scifir::atan_degree(new_y / new_x);
342 float new_phi = scifir::acos_degree(new_z / new_value);
343 return vector_unit_3d(new_value,init_dimensions,angle(new_theta),angle(new_phi));
344 }
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
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_3d vector_unit_3d::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 346 of file vector_unit_3d.hpp.

347 {
348 float new_value = float(std::sqrt(std::pow(new_p,2) + std::pow(new_z,2)));
349 float new_phi = scifir::atan_degree(new_p / new_z);
350 return vector_unit_3d(new_value,init_dimensions,new_theta,angle(new_phi));
351 }

◆ initialize_from_string()

void vector_unit_3d::initialize_from_string ( string  init_vector_3d)
protected

Initializes the member-variables with the initialization string of vector_unit_3d init_vector_3d.

Definition at line 438 of file vector_unit_3d.cpp.

439 {
440 vector<string> values;
441 boost::split(values,init_vector_3d,boost::is_any_of(" "));
442 if (values.size() == 4)
443 {
444 scalar_unit::initialize_from_string(values[0] + " " + values[1],vector<dimension>());
445 theta = angle(values[2]);
446 phi = angle(values[3]);
447 }
448 }
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 vector_unit_3d::invert ( )
inline

Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to theta and calculating the new phi as "180 - phi".

Definition at line 458 of file vector_unit_3d.hpp.

459 {
460 theta.invert();
461 phi = 180.0f - phi;
462 }
void invert()
Inverts the angle to the opposite direction in a 2D plane, which is to add 180 degrees....
Definition angle.cpp:250

◆ operator*() [1/2]

vector_unit_3d vector_unit_3d::operator* ( const scalar_unit x) const

It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.

Definition at line 356 of file vector_unit_3d.cpp.

357 {
358 long double new_value = scalar_unit::value * x.get_value();
359 vector<dimension> new_dimensions = multiply_dimensions(get_dimensions(), x.get_dimensions(),new_value);
360 return vector_unit_3d(float(new_value), new_dimensions, theta, phi);
361 }
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_3d vector_unit_3d::operator* ( T  x) const
inline

It creates a new vector as the multiplication of the numeric type x to the value. Theta and phi are not changed.

Definition at line 390 of file vector_unit_3d.hpp.

391 {
392 vector_unit_3d y = *this;
393 y *= x;
394 return y;
395 }

◆ operator*=()

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

It multiplies the numeric type x to the value. Theta and phi are not changed.

Definition at line 424 of file vector_unit_3d.hpp.

425 {
426 scalar_unit::value *= std::abs(x);
427 if(x < 0)
428 {
429 invert();
430 }
431 }
void invert()
Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to ...

◆ operator+() [1/2]

vector_unit_3d vector_unit_3d::operator+ ( const vector_unit_3d x) const

Addition of vectors in 3D. It creates a new vector as the addition of the other two.

Definition at line 319 of file vector_unit_3d.cpp.

320 {
321 if (has_dimensions(x))
322 {
323 float new_x = float(x_projection() + x.x_projection());
324 float new_y = float(y_projection() + x.y_projection());
325 float new_z = float(z_projection() + x.z_projection());
326 float new_value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
327 angle new_theta = angle(cartesian_3d_to_spherical_theta(new_x, new_y, new_z));
328 angle new_phi = angle(cartesian_3d_to_spherical_phi(new_x, new_y, new_z));
329 return vector_unit_3d(new_value,get_dimensions(),new_theta,new_phi);
330 }
331 else
332 {
333 return vector_unit_3d();
334 }
335 }
bool has_dimensions(const string &init_dimensions) const
Checks if the basic dimensions are the same as the initialization string of 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,...
scalar_unit x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same 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...
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_3d vector_unit_3d::operator+ ( T  x) const
inline

It creates a new vector as the addition of the numeric type x to the value. Theta and phi are not changed.

Definition at line 374 of file vector_unit_3d.hpp.

375 {
376 vector_unit_3d y = *this;
377 y += x;
378 return y;
379 }

◆ operator+=() [1/2]

void vector_unit_3d::operator+= ( const vector_unit_3d x)

The vector_unit_3d is summed as vector, in spherical coordinates. The addition of vectors is used for the calculation.

Definition at line 289 of file vector_unit_3d.cpp.

290 {
291 if(has_dimensions(x))
292 {
293 float new_x = float(x_projection() + x.x_projection());
294 float new_y = float(y_projection() + x.y_projection());
295 float new_z = float(z_projection() + x.z_projection());
296 scalar_unit::value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
297 theta = angle(cartesian_3d_to_spherical_theta(new_x, new_y, new_z));
298 phi = angle(cartesian_3d_to_spherical_phi(new_x, new_y, new_z));
299 }
300 else
301 {
302 cerr << "Cannot sum vectors of different dimensions" << endl;
303 }
304 }

◆ operator+=() [2/2]

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

It sums the numeric type x to the value. Theta and phi are not changed.

Definition at line 412 of file vector_unit_3d.hpp.

413 {
415 }

◆ operator-() [1/2]

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

It creates a new vector as the substraction of the numeric type x to the value. Theta and phi are not changed.

Definition at line 382 of file vector_unit_3d.hpp.

383 {
384 vector_unit_3d y = *this;
385 y -= x;
386 return y;
387 }

◆ operator-() [2/2]

vector_unit_3d vector_unit_3d::operator- ( vector_unit_3d  x) const

Substraction of vectors in 3D. It creates a new vector as the difference of the other two.

Definition at line 337 of file vector_unit_3d.cpp.

338 {
339 if (has_dimensions(x))
340 {
341 x.invert();
342 float new_x = float(x_projection() + x.x_projection());
343 float new_y = float(y_projection() + x.y_projection());
344 float new_z = float(z_projection() + x.z_projection());
345 float new_value = cartesian_3d_to_spherical_r(new_x, new_y, new_z);
346 angle new_theta = angle(cartesian_3d_to_spherical_theta(new_x, new_y, new_z));
347 angle new_phi = angle(cartesian_3d_to_spherical_phi(new_x, new_y, new_z));
348 return vector_unit_3d(new_value,get_dimensions(),new_theta,new_phi);
349 }
350 else
351 {
352 return vector_unit_3d();
353 }
354 }

◆ operator-=() [1/2]

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

It substracts the numeric type x to the value. Theta and phi are not changed.

Definition at line 418 of file vector_unit_3d.hpp.

419 {
421 }

◆ operator-=() [2/2]

void vector_unit_3d::operator-= ( vector_unit_3d  x)

The vector_unit_3d is substracted as vector, in spherical coordinates. The substraction of vectors is used for the calculation.

Definition at line 306 of file vector_unit_3d.cpp.

307 {
308 if(has_dimensions(x))
309 {
310 x.invert();
311 *this += x;
312 }
313 else
314 {
315 cerr << "Cannot substract vectors of different dimensions" << endl;
316 }
317 }

◆ operator/() [1/2]

vector_unit_3d vector_unit_3d::operator/ ( const scalar_unit x) const

It creates a new vector_unit_3d scaling a vector_unit_3d by the inverse of the scalar_unit x.

Definition at line 363 of file vector_unit_3d.cpp.

364 {
365 long double new_value = scalar_unit::value / x.get_value();
366 vector<dimension> new_dimensions = divide_dimensions(get_dimensions(), x.get_dimensions(),new_value);
367 return vector_unit_3d(float(new_value), new_dimensions, theta, phi);
368 }
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_3d vector_unit_3d::operator/ ( T  x) const
inline

It creates a new vector as the division of the value with the numeric type x. Theta and phi are not changed.

Definition at line 398 of file vector_unit_3d.hpp.

399 {
400 vector_unit_3d y = *this;
401 y /= x;
402 return y;
403 }

◆ operator/=()

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

It divides the numeric type x to the value. Theta and phi are not changed.

Definition at line 434 of file vector_unit_3d.hpp.

435 {
436 scalar_unit::value /= std::abs(x);
437 if(x < 0)
438 {
439 invert();
440 }
441 }

◆ operator=() [1/5]

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

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

Definition at line 124 of file vector_unit_3d.cpp.

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

◆ operator=() [2/5]

vector_unit_3d & vector_unit_3d::operator= ( const string init_vector_3d)

The value, the dimensions, theta and phi are set from the initialization string init_vector_3d.

Definition at line 136 of file vector_unit_3d.cpp.

137 {
139 return *this;
140 }

◆ operator=() [3/5]

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

Copy assignment. The member-variables are copied from the vector_unit_3d x.

Definition at line 108 of file vector_unit_3d.cpp.

109 {
111 theta = x.theta;
112 phi = x.phi;
113 return *this;
114 }

◆ operator=() [4/5]

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

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

Definition at line 130 of file vector_unit_3d.cpp.

131 {
132 scalar_unit::operator =(std::move(x));
133 return *this;
134 }

◆ operator=() [5/5]

vector_unit_3d & vector_unit_3d::operator= ( vector_unit_3d &&  x)

Move assignment. The member-variables are moved from the vector_unit_3d x.

Definition at line 116 of file vector_unit_3d.cpp.

117 {
118 scalar_unit::operator =(std::move(x));
119 theta = std::move(x.theta);
120 phi = std::move(x.phi);
121 return *this;
122 }

◆ operator==()

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

Comparison operator. Two vector_unit_3d are equal if their value, dimensions, theta and phi are the same.

Definition at line 142 of file vector_unit_3d.cpp.

143 {
144 x.change_dimensions(*this);
145 if(get_value() == x.get_value() and scifir::same_direction(*this,x) and has_dimensions(x))
146 {
147 return true;
148 }
149 else
150 {
151 return false;
152 }
153 }
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_3d vector_unit_3d::operator^ ( const scalar_unit x) const

It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.

Definition at line 370 of file vector_unit_3d.cpp.

371 {
372 if(x.has_empty_dimensions())
373 {
375 return vector_unit_3d(new_unit, theta, phi);
376 }
377 else
378 {
379 cerr << "Cannot power with as exponent a unit with dimensions" << endl;
380 return vector_unit_3d();
381 }
382 }
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_3d vector_unit_3d::operator^ ( T  x) const
inline

It creates a new vector as the power of the value with the numeric type x. Theta and phi are not changed.

Definition at line 406 of file vector_unit_3d.hpp.

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

◆ point_to()

void vector_unit_3d::point_to ( direction::name  x)

Theta is set to the direction specified in 3D. 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 155 of file vector_unit_3d.cpp.

156 {
157 if (x == direction::LEFT)
158 {
159 theta = 270.0f;
160 phi = 90.0f;
161 }
162 else if(x == direction::RIGHT)
163 {
164 theta = 90.0f;
165 phi = 90.0f;
166 }
167 else if(x == direction::TOP)
168 {
169 theta = 0.0f;
170 phi = 0.0f;
171 }
172 else if(x == direction::BOTTOM)
173 {
174 theta = 0.0f;
175 phi = 180.0f;
176 }
177 else if(x == direction::LEFT_TOP)
178 {
179 theta = 270.0f;
180 phi = 45.0f;
181 }
182 else if(x == direction::RIGHT_TOP)
183 {
184 theta = 90.0f;
185 phi = 45.0f;
186 }
187 else if(x == direction::RIGHT_BOTTOM)
188 {
189 theta = 90.0f;
190 phi = 135.0f;
191 }
192 else if(x == direction::LEFT_BOTTOM)
193 {
194 theta = 270.0f;
195 phi = 135.0f;
196 }
197 else if(x == direction::FRONT)
198 {
199 theta = 0.0f;
200 phi = 90.0f;
201 }
202 else if(x == direction::BACK)
203 {
204 theta = 180.0f;
205 phi = 90.0f;
206 }
207 else if(x == direction::LEFT_FRONT)
208 {
209 theta = 315.0f;
210 phi = 90.0f;
211 }
212 else if(x == direction::RIGHT_FRONT)
213 {
214 theta = 45.0f;
215 phi = 90.0f;
216 }
217 else if(x == direction::TOP_FRONT)
218 {
219 theta = 0.0f;
220 phi = 45.0f;
221 }
222 else if(x == direction::BOTTOM_FRONT)
223 {
224 theta = 0.0f;
225 phi = 135.0f;
226 }
227 else if(x == direction::LEFT_BACK)
228 {
229 theta = 225.0f;
230 phi = 90.0f;
231 }
232 else if(x == direction::RIGHT_BACK)
233 {
234 theta = 135.0f;
235 phi = 90.0f;
236 }
237 else if(x == direction::TOP_BACK)
238 {
239 theta = 180.0f;
240 phi = 45.0f;
241 }
242 else if(x == direction::BOTTOM_BACK)
243 {
244 theta = 180.0f;
245 phi = 135.0f;
246 }
247 else if(x == direction::LEFT_TOP_FRONT)
248 {
249 theta = 315.0f;
250 phi = 45.0f;
251 }
252 else if(x == direction::RIGHT_TOP_FRONT)
253 {
254 theta = 45.0f;
255 phi = 45.0f;
256 }
257 else if(x == direction::LEFT_BOTTOM_FRONT)
258 {
259 theta = 315.0f;
260 phi = 135.0f;
261 }
263 {
264 theta = 45.0f;
265 phi = 135.0f;
266 }
267 else if(x == direction::LEFT_TOP_BACK)
268 {
269 theta = 225.0f;
270 phi = 45.0f;
271 }
272 else if(x == direction::RIGHT_TOP_BACK)
273 {
274 theta = 135.0f;
275 phi = 45.0f;
276 }
277 else if(x == direction::LEFT_BOTTOM_BACK)
278 {
279 theta = 225.0f;
280 phi = 135.0f;
281 }
282 else if(x == direction::RIGHT_BOTTOM_BACK)
283 {
284 theta = 135.0f;
285 phi = 135.0f;
286 }
287 }

◆ vectorial_base_display()

string vector_unit_3d::vectorial_base_display ( int  number_of_decimals = 2) const

Displays the vector as the string representation of the scalar unit adding also the angle theta and the angle phi. It displays the dimensions with its base dimensions.

◆ vectorial_custom_display()

string vector_unit_3d::vectorial_custom_display ( const string init_dimensions,
int  number_of_decimals = 2 
) const

Displays the vector as the string representation of the scalar unit adding also the angle theta and the angle phi. It displays the vector in the dimensions specified in the initialization string of dimensions init_dimensions.

◆ vectorial_display()

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

Displays the vector as the string representation of the scalar unit adding also the angle theta and the angle phi.

◆ x_projection()

scalar_unit vector_unit_3d::x_projection ( ) const
inline

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.

Definition at line 443 of file vector_unit_3d.hpp.

444 {
446 }
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_3d::y_projection ( ) const
inline

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.

Definition at line 448 of file vector_unit_3d.hpp.

◆ z_projection()

scalar_unit vector_unit_3d::z_projection ( ) const
inline

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.

Definition at line 453 of file vector_unit_3d.hpp.

Member Data Documentation

◆ phi

angle vector_unit_3d::phi

Angle phi of the vector in 3D space, in spherical coordinates. As all angles of scifir-units, it's stored in degrees.

Definition at line 469 of file vector_unit_3d.hpp.

◆ theta

angle vector_unit_3d::theta

Angle theta of the vector in 3D space, in spherical coordinates. As all angles of scifir-units, it's stored in degrees.

Definition at line 468 of file vector_unit_3d.hpp.


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