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
|
#include "./scalar_unit.hpp"
#include "../meca_number/angle.hpp"
#include "../util/is_number.hpp"
#include "../coordinates/direction.hpp"
#include "boost/algorithm/string.hpp"
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
Go to the source code of this file.
Classes | |
class | scifir::vector_unit_nd |
Class that creates a vector in ND, which means a variable number of dimensions. A vector_unit_nd can change to be in 1D, in 2D or in 3D, but it cannot be in more than one dimension at the same time. The member-variables of vector_unit_nd are the value and the vector<dimension> of scalar_unit, and a vector<angle> angles. The number of angles is equal to the number of dimensions vector unit has - 1. In 1D vector_unit_nd doesn't has angles, in 2D vector_unit_nd is in polar coordinates and has 1 angle, and in 3D vector_unit_nd is in spherical coordinates and has 2 angles. All base and derived vectorial unit classes in ND inherit from vector_unit_nd, and add the suffix **_nd** in their name. Initialization string example: "1 N 20° 30° 40°". '°' is the Unicode Character U+00B0. More... | |
Namespaces | |
namespace | scifir |
The namespace scifir contains all scifir-units, excepting the string literals, which are outside. | |
Macros | |
#define | VECTOR_UNIT_ND_HPP_BEGIN(name) |
#define | VECTOR_UNIT_ND_HPP_END() |
#define | VECTOR_UNIT_ND_HPP(name) |
#define | VECTOR_UNIT_ND_CPP(name, init_real_dimensions) |
Functions | |
string | scifir::to_string (const vector_unit_nd &x) |
It generates a string representation of vector_unit_nd. | |
scalar_unit | scifir::norm (const vector_unit_nd &x) |
It returns the value of the vector, which is the value in 1D, p in 2D (polar coordinates), or r in 3D (spherical coordinates). | |
vector_unit_nd | scifir::sqrt (const vector_unit_nd &x) |
It squares the vector, creating a vector_unit_nd with the value squared and always the same angles. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes. | |
vector_unit_nd | scifir::sqrt_nth (const vector_unit_nd &x, int index) |
It takes the root of the vector with the index given, creating a vector_unit_nd with the value rooted to that index and always maintains the same angles. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes. | |
scalar_unit | scifir::dot_product (const vector_unit_nd &x, const vector_unit_nd &y) |
Creates a scalar_unit as the dot product of the two vectors x and y. | |
vector_unit_nd | scifir::cross_product (const vector_unit_nd &x, const vector_unit_nd &y) |
Creates a vector_unit_nd as the cross product of the two vectors x and y. If both vectors aren't in 3D, it returns an empty vector_unit_nd, because the cross product doesn't exists outside 3D. | |
angle | scifir::angle_between (const vector_unit_nd &x, const vector_unit_nd &y) |
Returns the angle between two vectors x and y inside the ND space, which can be 2D or 3D, depending on the ND of the vectors. If the vectors have different ND, it returns an empty vector_unit_nd instead. | |
bool | scifir::same_nd (const vector_unit_nd &x, const vector_unit_nd &y) |
Checks if two vectors have the same number of dimensions. | |
bool | scifir::same_direction (const vector_unit_nd &x, const vector_unit_nd &y) |
Checks if two vectors x and y have the same direction. Both vectors must have the same ND, otherwise it returns an empty vector_unit_nd instead. | |
bool | scifir::parallel (const vector_unit_nd &x, const vector_unit_nd &y) |
Checks if two vectors x and y are parallel, which means that their direction is the same or the exact opposite. Both vectors must have the same ND, otherwise it returns an empty vector_unit_nd instead. | |
bool | scifir::orthogonal (const vector_unit_nd &x, const vector_unit_nd &y) |
Checks if two vectors x and y are orthogonal, that's, if they have 90 degrees between them. Both vectors must have the same ND, otherwise it returns an empty vector_unit_nd instead. | |
scifir::vector_unit_nd | operator* (const scifir::scalar_unit &x, const scifir::vector_unit_nd &y) |
It creates a new vector_unitn3d scaling a vector_unit_nd by the scalar_unit x. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::vector_unit_nd | operator+ (const T y, const scifir::vector_unit_nd &x) |
It creates a new vector as the addition of the numeric type x to the value. The angles are not changed. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::vector_unit_nd | operator- (const T y, const scifir::vector_unit_nd &x) |
It creates a new vector as the substraction of the numeric type x to the value. The angles are not changed. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::vector_unit_nd | operator* (const T y, const scifir::vector_unit_nd &x) |
It creates a new vector as the multiplication of the numeric type x to the value. The angles are not changed. | |
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type> | |
scifir::vector_unit_nd | operator/ (const T y, const scifir::vector_unit_nd &x) |
It creates a new vector as the division of the value with the numeric type x. The angles are not changed. | |
bool | operator!= (const scifir::vector_unit_nd &x, const scifir::vector_unit_nd &y) |
Comparison operator. Two vector_unit_nd are not equal if their value, dimensions or angles are different. | |
bool | operator== (const scifir::vector_unit_nd &x, const string &init_vector_nd) |
Returns true if x is equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator!= (const scifir::vector_unit_nd &x, const string &init_vector_nd) |
Returns true if x is not equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator== (const string &init_vector_nd, const scifir::vector_unit_nd &x) |
Returns true if x is equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers. | |
bool | operator!= (const string &init_vector_nd, const scifir::vector_unit_nd &x) |
Returns true if x is not equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers. | |
void | operator+= (string &x, const scifir::vector_unit_nd &y) |
Concatenates the string representation of the vector_unit_nd y to the string x. | |
string | operator+ (const string &x, const scifir::vector_unit_nd &y) |
Creates a new string as the concatenation of the string x with the representation string of the vector_unit_nd y. | |
string | operator+ (const scifir::vector_unit_nd &y, const string &x) |
Creates a new string as the concatenation of the string x with the representation string of the vector_unit_nd y. | |
ostream & | operator<< (ostream &os, const scifir::vector_unit_nd &x) |
Adds the string representation of the vector_unit_nd x to an output stream os. | |
istream & | operator>> (istream &is, scifir::vector_unit_nd &x) |
Allows that an istream initializes by string a vector_unit_nd x. | |
#define VECTOR_UNIT_ND_CPP | ( | name, | |
init_real_dimensions | |||
) |
Definition at line 132 of file vector_unit_nd.hpp.
#define VECTOR_UNIT_ND_HPP | ( | name | ) |
Definition at line 76 of file vector_unit_nd.hpp.
#define VECTOR_UNIT_ND_HPP_BEGIN | ( | name | ) |
Definition at line 19 of file vector_unit_nd.hpp.
#define VECTOR_UNIT_ND_HPP_END | ( | ) |
Definition at line 71 of file vector_unit_nd.hpp.
bool operator!= | ( | const scifir::vector_unit_nd & | x, |
const scifir::vector_unit_nd & | y | ||
) |
Comparison operator. Two vector_unit_nd are not equal if their value, dimensions or angles are different.
Definition at line 947 of file vector_unit_nd.cpp.
bool operator!= | ( | const scifir::vector_unit_nd & | x, |
const string & | init_vector_nd | ||
) |
Returns true if x is not equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 958 of file vector_unit_nd.cpp.
bool operator!= | ( | const string & | init_vector_nd, |
const scifir::vector_unit_nd & | x | ||
) |
Returns true if x is not equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 969 of file vector_unit_nd.cpp.
scifir::vector_unit_nd operator* | ( | const scifir::scalar_unit & | x, |
const scifir::vector_unit_nd & | y | ||
) |
It creates a new vector_unitn3d scaling a vector_unit_nd by the scalar_unit x.
Definition at line 925 of file vector_unit_nd.cpp.
scifir::vector_unit_nd operator* | ( | const T | y, |
const scifir::vector_unit_nd & | x | ||
) |
It creates a new vector as the multiplication of the numeric type x to the value. The angles are not changed.
Definition at line 623 of file vector_unit_nd.hpp.
string operator+ | ( | const scifir::vector_unit_nd & | y, |
const string & | x | ||
) |
Creates a new string as the concatenation of the string x with the representation string of the vector_unit_nd y.
Definition at line 989 of file vector_unit_nd.cpp.
string operator+ | ( | const string & | x, |
const scifir::vector_unit_nd & | y | ||
) |
Creates a new string as the concatenation of the string x with the representation string of the vector_unit_nd y.
Definition at line 981 of file vector_unit_nd.cpp.
scifir::vector_unit_nd operator+ | ( | const T | y, |
const scifir::vector_unit_nd & | x | ||
) |
It creates a new vector as the addition of the numeric type x to the value. The angles are not changed.
Definition at line 609 of file vector_unit_nd.hpp.
void operator+= | ( | string & | x, |
const scifir::vector_unit_nd & | y | ||
) |
Concatenates the string representation of the vector_unit_nd y to the string x.
Definition at line 974 of file vector_unit_nd.cpp.
scifir::vector_unit_nd operator- | ( | const T | y, |
const scifir::vector_unit_nd & | x | ||
) |
It creates a new vector as the substraction of the numeric type x to the value. The angles are not changed.
Definition at line 617 of file vector_unit_nd.hpp.
scifir::vector_unit_nd operator/ | ( | const T | y, |
const scifir::vector_unit_nd & | x | ||
) |
It creates a new vector as the division of the value with the numeric type x. The angles are not changed.
Definition at line 631 of file vector_unit_nd.hpp.
ostream & operator<< | ( | ostream & | os, |
const scifir::vector_unit_nd & | x | ||
) |
Adds the string representation of the vector_unit_nd x to an output stream os.
Definition at line 997 of file vector_unit_nd.cpp.
bool operator== | ( | const scifir::vector_unit_nd & | x, |
const string & | init_vector_nd | ||
) |
Returns true if x is equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 952 of file vector_unit_nd.cpp.
bool operator== | ( | const string & | init_vector_nd, |
const scifir::vector_unit_nd & | x | ||
) |
Returns true if x is equal to the vector_unit_nd initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
Definition at line 963 of file vector_unit_nd.cpp.
istream & operator>> | ( | istream & | is, |
scifir::vector_unit_nd & | x | ||
) |
Allows that an istream initializes by string a vector_unit_nd x.
Definition at line 1011 of file vector_unit_nd.cpp.