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

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

#include <vector_unit_2d.hpp>

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

Public Member Functions

 vector_unit_2d ()
 Default constructor. The value is set to 0, the dimensions are empty and theta is 0.
 
 vector_unit_2d (const vector_unit_2d &x)
 Copy constructor. The member-variables are copied from the vector_unit_2d x.
 
 vector_unit_2d (vector_unit_2d &&x)
 Move constructor. The member-variables are moved from the vector_unit_2d x.
 
 vector_unit_2d (float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle &new_theta, dimension::position new_position=dimension::NUMERATOR)
 
 vector_unit_2d (float new_value, const string &init_dimensions, float new_theta)
 The value is new_value, the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (float new_value, const string &init_dimensions, const angle &new_theta)
 The value is new_value, the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (double new_value, const string &init_dimensions, float new_theta)
 The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (double new_value, const string &init_dimensions, const angle &new_theta)
 The value is new_value (the double is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (long double new_value, const string &init_dimensions, float new_theta)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (long double new_value, const string &init_dimensions, const angle &new_theta)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (int new_value, const string &init_dimensions, float new_theta)
 The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (int new_value, const string &init_dimensions, const angle &new_theta)
 The value is new_value (the int is casted to a float), the dimensions are initialized with the initialization string of dimensions, and theta is new_theta.
 
 vector_unit_2d (float new_value, const vector< dimension > &new_dimensions, float new_theta)
 The value is new_value, the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (float new_value, const vector< dimension > &new_dimensions, const angle &new_theta)
 The value is new_value, the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (double new_value, const vector< dimension > &new_dimensions, float new_theta)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (double new_value, const vector< dimension > &new_dimensions, const angle &new_theta)
 The value is new_value (the double is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (long double new_value, const vector< dimension > &new_dimensions, float new_theta)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (long double new_value, const vector< dimension > &new_dimensions, const angle &new_theta)
 The value is new_value (the long double is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (int new_value, const vector< dimension > &new_dimensions, float new_theta)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (int new_value, const vector< dimension > &new_dimensions, const angle &new_theta)
 The value is new_value (the int is casted to a float), the dimensions are initialized with a vector of dimensions, and theta is new_theta.
 
 vector_unit_2d (const scalar_unit &x, float new_theta)
 The value and the dimensions are copied from the scalar_unit x, theta is new_theta.
 
 vector_unit_2d (const scalar_unit &x, const angle &new_theta)
 The value and the dimensions are copied from the scalar_unit x, theta is new_theta.
 
 vector_unit_2d (const string &init_scalar, float new_theta)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta.
 
 vector_unit_2d (const string &init_scalar, const angle &new_theta)
 The value and the dimensions are copied from the initialization string of scalar_unit init_scalar, theta is new_theta.
 
 vector_unit_2d (const string &init_vector_2d)
 The value, the dimensions and theta are initialized from the initialization string of vector_unit_2d init_vector_2d.
 
vector_unit_2doperator= (const vector_unit_2d &x)
 Copy assignment. The member-variables are copied from the vector_unit_2d x.
 
vector_unit_2doperator= (vector_unit_2d &&x)
 Move assignment. The member-variables are moved from the vector_unit_2d x.
 
vector_unit_2doperator= (const scalar_unit &x)
 The value and the dimensions are copied from the scalar_unit x, theta is not changed.
 
vector_unit_2doperator= (scalar_unit &&x)
 The value and the dimensions are moved from the scalar_unit x, theta is not changed.
 
vector_unit_2doperator= (const string &init_vector_2d)
 The value, the dimensions and theta are set from the initialization string init_vector_2d.
 
bool operator== (vector_unit_2d x) const
 Comparison operator. Two vector_unit_2d are equal if their value, dimensions and theta are the same.
 
void point_to (direction::name x)
 Theta is set to the direction specified in 2D. Possible values are LEFT, RIGHT, TOP, BOTTOM, LEFT_TOP, RIGHT_TOP, RIGHT_BOTTOM, LEFT_BOTTOM.
 
void operator+= (const vector_unit_2d &x)
 The vector_unit_2d is summed as vector, in polar coordinates. The addition of vectors is used for the calculation.
 
void operator-= (vector_unit_2d x)
 The vector_unit_2d is substracted as vector, in polar coordinates. The substraction of vectors is used for the calculation.
 
vector_unit_2d operator+ (const vector_unit_2d &x) const
 Addition of vectors in 2D. It creates a new vector as the addition of the other two.
 
vector_unit_2d operator- (vector_unit_2d x) const
 Substraction of vectors in 2D. It creates a new vector as the difference of the other two.
 
vector_unit_2d operator* (const scalar_unit &x) const
 It creates a new vector_unit_2d scaling a vector_unit_2d by the scalar_unit x.
 
vector_unit_2d operator/ (const scalar_unit &x) const
 It creates a new vector_unit_2d scaling a vector_unit_2d by the inverse of the scalar_unit x.
 
vector_unit_2d 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_2d operator+ (T x) const
 It creates a new vector as the addition of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_2d operator- (T x) const
 It creates a new vector as the substraction of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_2d operator* (T x) const
 It creates a new vector as the multiplication of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
vector_unit_2d operator/ (T x) const
 It creates a new vector as the division of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<is_integer_number<T>::value>::type>
vector_unit_2d operator^ (T x) const
 It creates a new vector as the power of the numeric type x to the value. Theta is 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 is 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 is 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 is 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 is 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.
 
void invert ()
 Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to theta.
 
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.
 
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. 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. 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_2d 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.
 

Public Attributes

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

Protected Member Functions

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

Definition at line 295 of file vector_unit_2d.hpp.

Constructor & Destructor Documentation

◆ vector_unit_2d() [1/32]

vector_unit_2d::vector_unit_2d ( )

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

Definition at line 12 of file vector_unit_2d.cpp.

12 : scalar_unit(),theta()
13 {}
scalar_unit()
Default constructor, the value is 0 and the dimensions are empty.
angle theta
Angle of the vector in 2D space, in polar coordinates. As all angles of scifir-units,...

◆ vector_unit_2d() [2/32]

vector_unit_2d::vector_unit_2d ( const vector_unit_2d x)

Copy constructor. The member-variables are copied from the vector_unit_2d x.

Definition at line 15 of file vector_unit_2d.cpp.

15 : scalar_unit(x),theta(x.theta)
16 {}

◆ vector_unit_2d() [3/32]

vector_unit_2d::vector_unit_2d ( vector_unit_2d &&  x)

Move constructor. The member-variables are moved from the vector_unit_2d x.

Definition at line 18 of file vector_unit_2d.cpp.

18 : scalar_unit(std::move(x)),theta(std::move(x.theta))
19 {}

◆ vector_unit_2d() [4/32]

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

Definition at line 21 of file vector_unit_2d.cpp.

21 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
22 {}

◆ vector_unit_2d() [5/32]

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

Definition at line 24 of file vector_unit_2d.cpp.

24 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
25 {}

◆ vector_unit_2d() [6/32]

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

Definition at line 27 of file vector_unit_2d.cpp.

27 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
28 {}

◆ vector_unit_2d() [7/32]

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

Definition at line 30 of file vector_unit_2d.cpp.

30 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
31 {}

◆ vector_unit_2d() [8/32]

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

Definition at line 33 of file vector_unit_2d.cpp.

33 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
34 {}

◆ vector_unit_2d() [9/32]

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

Definition at line 36 of file vector_unit_2d.cpp.

36 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
37 {}

◆ vector_unit_2d() [10/32]

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

Definition at line 39 of file vector_unit_2d.cpp.

39 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
40 {}

◆ vector_unit_2d() [11/32]

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

Definition at line 42 of file vector_unit_2d.cpp.

42 : scalar_unit(new_value,new_dimension,new_prefix,new_position),theta(new_theta)
43 {}

◆ vector_unit_2d() [12/32]

vector_unit_2d::vector_unit_2d ( float  new_value,
const string init_dimensions,
float  new_theta 
)
explicit

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

Definition at line 45 of file vector_unit_2d.cpp.

45 : scalar_unit(new_value,init_dimensions),theta(new_theta)
46 {}

◆ vector_unit_2d() [13/32]

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

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

Definition at line 48 of file vector_unit_2d.cpp.

48 : scalar_unit(new_value,init_dimensions),theta(new_theta)
49 {}

◆ vector_unit_2d() [14/32]

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

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

Definition at line 51 of file vector_unit_2d.cpp.

51 : scalar_unit(new_value,init_dimensions),theta(new_theta)
52 {}

◆ vector_unit_2d() [15/32]

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

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

Definition at line 54 of file vector_unit_2d.cpp.

54 : scalar_unit(new_value,init_dimensions),theta(new_theta)
55 {}

◆ vector_unit_2d() [16/32]

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

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

Definition at line 57 of file vector_unit_2d.cpp.

57 : scalar_unit(new_value,init_dimensions),theta(new_theta)
58 {}

◆ vector_unit_2d() [17/32]

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

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

Definition at line 60 of file vector_unit_2d.cpp.

60 : scalar_unit(new_value,init_dimensions),theta(new_theta)
61 {}

◆ vector_unit_2d() [18/32]

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

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

Definition at line 63 of file vector_unit_2d.cpp.

63 : scalar_unit(new_value,init_dimensions),theta(new_theta)
64 {}

◆ vector_unit_2d() [19/32]

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

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

Definition at line 66 of file vector_unit_2d.cpp.

66 : scalar_unit(new_value,init_dimensions),theta(new_theta)
67 {}

◆ vector_unit_2d() [20/32]

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

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

Definition at line 69 of file vector_unit_2d.cpp.

69 : scalar_unit(new_value,new_dimensions),theta(new_theta)
70 {}

◆ vector_unit_2d() [21/32]

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

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

Definition at line 72 of file vector_unit_2d.cpp.

72 : scalar_unit(new_value,new_dimensions),theta(new_theta)
73 {}

◆ vector_unit_2d() [22/32]

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

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

Definition at line 75 of file vector_unit_2d.cpp.

75 : scalar_unit(new_value,new_dimensions),theta(new_theta)
76 {}

◆ vector_unit_2d() [23/32]

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

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

Definition at line 78 of file vector_unit_2d.cpp.

78 : scalar_unit(new_value,new_dimensions),theta(new_theta)
79 {}

◆ vector_unit_2d() [24/32]

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

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

Definition at line 81 of file vector_unit_2d.cpp.

81 : scalar_unit(new_value,new_dimensions),theta(new_theta)
82 {}

◆ vector_unit_2d() [25/32]

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

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

Definition at line 84 of file vector_unit_2d.cpp.

84 : scalar_unit(new_value,new_dimensions),theta(new_theta)
85 {}

◆ vector_unit_2d() [26/32]

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

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

Definition at line 87 of file vector_unit_2d.cpp.

87 : scalar_unit(new_value,new_dimensions),theta(new_theta)
88 {}

◆ vector_unit_2d() [27/32]

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

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

Definition at line 90 of file vector_unit_2d.cpp.

90 : scalar_unit(new_value,new_dimensions),theta(new_theta)
91 {}

◆ vector_unit_2d() [28/32]

vector_unit_2d::vector_unit_2d ( const scalar_unit x,
float  new_theta 
)
explicit

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

Definition at line 93 of file vector_unit_2d.cpp.

93 : scalar_unit(x),theta(new_theta)
94 {}

◆ vector_unit_2d() [29/32]

vector_unit_2d::vector_unit_2d ( const scalar_unit x,
const angle new_theta 
)
explicit

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

Definition at line 96 of file vector_unit_2d.cpp.

96 : scalar_unit(x),theta(new_theta)
97 {}

◆ vector_unit_2d() [30/32]

vector_unit_2d::vector_unit_2d ( const string init_scalar,
float  new_theta 
)
explicit

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

Definition at line 99 of file vector_unit_2d.cpp.

99 : scalar_unit(init_scalar),theta(new_theta)
100 {}

◆ vector_unit_2d() [31/32]

vector_unit_2d::vector_unit_2d ( const string init_scalar,
const angle new_theta 
)
explicit

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

Definition at line 102 of file vector_unit_2d.cpp.

102 : scalar_unit(init_scalar),theta(new_theta)
103 {}

◆ vector_unit_2d() [32/32]

vector_unit_2d::vector_unit_2d ( const string init_vector_2d)
explicit

The value, the dimensions and theta are initialized from the initialization string of vector_unit_2d init_vector_2d.

Definition at line 105 of file vector_unit_2d.cpp.

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

Member Function Documentation

◆ cartesian_2d()

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

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

Definition at line 331 of file vector_unit_2d.hpp.

332 {
333 float new_value = float(std::sqrt(std::pow(new_x,2) + std::pow(new_y,2)));
334 float new_theta = scifir::atan_degree(new_y / new_x);
335 return vector_unit_2d(new_value,init_dimensions,angle(new_theta));
336 }
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

◆ initialize_from_string()

void vector_unit_2d::initialize_from_string ( string  init_vector_2d)
protected

Initializes the member-variables with the initialization string of vector_unit_2d init_vector_2d.

Definition at line 334 of file vector_unit_2d.cpp.

335 {
336 vector<string> values;
337 boost::split(values,init_vector_2d,boost::is_any_of(" "));
338 if (values.size() == 3)
339 {
340 scalar_unit::initialize_from_string(values[0] + " " + values[1],vector<dimension>());
341 theta = angle(values[2]);
342 }
343 }
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_2d::invert ( )
inline

Changes the direction of the vector to the opposite direction. It does that by adding 180 degrees to theta.

Definition at line 438 of file vector_unit_2d.hpp.

439 {
440 theta.invert();
441 }
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_2d vector_unit_2d::operator* ( const scalar_unit x) const

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

Definition at line 252 of file vector_unit_2d.cpp.

253 {
254 long double new_value = (long double)(scalar_unit::value * x.get_value());
255 vector<dimension> new_dimensions = multiply_dimensions(get_dimensions(), x.get_dimensions(),new_value);
256 return vector_unit_2d(new_value, new_dimensions, theta);
257 }
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_2d vector_unit_2d::operator* ( T  x) const
inline

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

Definition at line 375 of file vector_unit_2d.hpp.

376 {
377 vector_unit_2d y = *this;
378 y *= x;
379 return y;
380 }

◆ operator*=()

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

It multiplies the numeric type x to the value. Theta is not changed.

Definition at line 409 of file vector_unit_2d.hpp.

410 {
411 scalar_unit::value *= std::abs(x);
412 if(x < 0)
413 {
414 theta.invert();
415 }
416 }

◆ operator+() [1/2]

vector_unit_2d vector_unit_2d::operator+ ( const vector_unit_2d x) const

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

Definition at line 219 of file vector_unit_2d.cpp.

220 {
221 if (has_dimensions(x))
222 {
223 float new_x = float(x_projection() + x.x_projection());
224 float new_y = float(y_projection() + x.y_projection());
225 float value = cartesian_2d_to_polar_p(new_x, new_y);
226 angle theta = cartesian_2d_to_polar_theta(new_x, new_y);
228 }
229 else
230 {
231 return vector_unit_2d();
232 }
233 }
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 x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions,...
angle cartesian_2d_to_polar_theta(const scalar_unit &x, scalar_unit y)
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit y)

◆ operator+() [2/2]

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

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

Definition at line 359 of file vector_unit_2d.hpp.

360 {
361 vector_unit_2d y = *this;
362 y += x;
363 return y;
364 }

◆ operator+=() [1/2]

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

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

Definition at line 191 of file vector_unit_2d.cpp.

192 {
193 if(has_dimensions(x))
194 {
195 float new_x = float(x_projection() + x.x_projection());
196 float new_y = float(y_projection() + x.y_projection());
198 theta = cartesian_2d_to_polar_theta(new_x, new_y);
199 }
200 else
201 {
202 cerr << "Cannot sum vectors of different dimensions" << endl;
203 }
204 }

◆ operator+=() [2/2]

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

It sums the numeric type x to the value. Theta is not changed.

Definition at line 397 of file vector_unit_2d.hpp.

398 {
400 }

◆ operator-() [1/2]

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

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

Definition at line 367 of file vector_unit_2d.hpp.

368 {
369 vector_unit_2d y = *this;
370 y -= x;
371 return y;
372 }

◆ operator-() [2/2]

vector_unit_2d vector_unit_2d::operator- ( vector_unit_2d  x) const

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

Definition at line 235 of file vector_unit_2d.cpp.

236 {
237 if (has_dimensions(x))
238 {
239 x.invert();
240 float new_x = float(x_projection() + x.x_projection());
241 float new_y = float(y_projection() + x.y_projection());
242 float value = cartesian_2d_to_polar_p(new_x, new_y);
243 angle theta = cartesian_2d_to_polar_theta(new_x, new_y);
245 }
246 else
247 {
248 return vector_unit_2d();
249 }
250 }

◆ operator-=() [1/2]

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

It substracts the numeric type x to the value. Theta is not changed.

Definition at line 403 of file vector_unit_2d.hpp.

404 {
406 }

◆ operator-=() [2/2]

void vector_unit_2d::operator-= ( vector_unit_2d  x)

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

Definition at line 206 of file vector_unit_2d.cpp.

207 {
208 if(has_dimensions(x))
209 {
210 x.invert();
211 *this += x;
212 }
213 else
214 {
215 cerr << "Cannot substract vectors of different dimensions" << endl;
216 }
217 }

◆ operator/() [1/2]

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

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

Definition at line 259 of file vector_unit_2d.cpp.

260 {
261 long double new_value = (long double)(scalar_unit::value / x.get_value());
262 vector<dimension> new_dimensions = divide_dimensions(get_dimensions(), x.get_dimensions(),new_value);
263 return vector_unit_2d(new_value, new_dimensions, theta);
264 }
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_2d vector_unit_2d::operator/ ( T  x) const
inline

It creates a new vector as the division of the numeric type x to the value. Theta is not changed.

Definition at line 383 of file vector_unit_2d.hpp.

384 {
385 vector_unit_2d y = *this;
386 y /= x;
387 return y;
388 }

◆ operator/=()

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

It divides the numeric type x to the value. Theta is not changed.

Definition at line 419 of file vector_unit_2d.hpp.

420 {
421 scalar_unit::value /= std::abs(x);
422 if(x < 0)
423 {
424 theta.invert();
425 }
426 }

◆ operator=() [1/5]

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

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

Definition at line 124 of file vector_unit_2d.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_2d & vector_unit_2d::operator= ( const string init_vector_2d)

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

Definition at line 136 of file vector_unit_2d.cpp.

137 {
139 return *this;
140 }

◆ operator=() [3/5]

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

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

Definition at line 110 of file vector_unit_2d.cpp.

111 {
113 theta = x.theta;
114 return *this;
115 }

◆ operator=() [4/5]

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

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

Definition at line 130 of file vector_unit_2d.cpp.

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

◆ operator=() [5/5]

vector_unit_2d & vector_unit_2d::operator= ( vector_unit_2d &&  x)

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

Definition at line 117 of file vector_unit_2d.cpp.

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

◆ operator==()

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

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

Definition at line 142 of file vector_unit_2d.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_2d vector_unit_2d::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 266 of file vector_unit_2d.cpp.

267 {
268 if(x.has_empty_dimensions())
269 {
271 return vector_unit_2d(new_unit, theta);
272 }
273 else
274 {
275 cerr << "Cannot power with as exponent a unit with dimensions" << endl;
276 return vector_unit_2d();
277 }
278 }
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_2d vector_unit_2d::operator^ ( T  x) const
inline

It creates a new vector as the power of the numeric type x to the value. Theta is not changed.

Definition at line 391 of file vector_unit_2d.hpp.

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

◆ point_to()

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

Theta is set to the direction specified in 2D. Possible values are LEFT, RIGHT, TOP, BOTTOM, LEFT_TOP, RIGHT_TOP, RIGHT_BOTTOM, LEFT_BOTTOM.

Definition at line 155 of file vector_unit_2d.cpp.

156 {
157 if (x == direction::LEFT)
158 {
159 theta = 180.0f;
160 }
161 else if(x == direction::RIGHT)
162 {
163 theta = 0.0f;
164 }
165 else if(x == direction::TOP)
166 {
167 theta = 90.0f;
168 }
169 else if(x == direction::BOTTOM)
170 {
171 theta = 270.0f;
172 }
173 else if(x == direction::LEFT_TOP)
174 {
175 theta = 135.0f;
176 }
177 else if(x == direction::RIGHT_TOP)
178 {
179 theta = 45.0f;
180 }
181 else if(x == direction::RIGHT_BOTTOM)
182 {
183 theta = 315.0f;
184 }
185 else if(x == direction::LEFT_BOTTOM)
186 {
187 theta = 225.0f;
188 }
189 }

◆ vectorial_base_display()

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

◆ vectorial_custom_display()

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

◆ vectorial_display()

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

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

◆ x_projection()

scalar_unit vector_unit_2d::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 428 of file vector_unit_2d.hpp.

429 {
431 }
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

◆ y_projection()

scalar_unit vector_unit_2d::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 433 of file vector_unit_2d.hpp.

434 {
436 }
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

Member Data Documentation

◆ theta

angle vector_unit_2d::theta

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

Definition at line 447 of file vector_unit_2d.hpp.


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