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
Namespaces | Functions
vector_unit_3d.cpp File Reference
#include "./vector_unit_3d.hpp"
#include "../coordinates/coordinates_3d.hpp"
#include "../util/types.hpp"
Include dependency graph for vector_unit_3d.cpp:

Go to the source code of this file.

Namespaces

namespace  scifir
 The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
 

Functions

scalar_unit scifir::norm (const vector_unit_3d &x)
 It returns the value of the vector in spherical coordinates, r.
 
vector_unit_3d scifir::sqrt (const vector_unit_3d &x)
 It squares the vector, creating a vector_unit_3d with the value squared and always the same theta and the same phi. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes.
 
vector_unit_3d scifir::sqrt_nth (const vector_unit_3d &x, int index)
 It takes the root of the vector with the index given, creating a vector_unit_3d with the value rooted to that index and always maintains the same theta and the same phi. 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_3d &x, const vector_unit_3d &y)
 Creates a scalar_unit as the dot product of the two vectors x and y.
 
vector_unit_3d scifir::cross_product (const vector_unit_3d &x, const vector_unit_3d &y)
 Creates a vector_unit_3d as the cross product of the two vectors x and y.
 
angle scifir::angle_between (const vector_unit_3d &x, const vector_unit_3d &y)
 Returns the angle between two vectors x and y inside a 3D space.
 
bool scifir::same_direction (const vector_unit_3d &x, const vector_unit_3d &y)
 Checks if two vectors x and y have the same direction.
 
bool scifir::parallel (const vector_unit_3d &x, const vector_unit_3d &y)
 Checks if two vectors x and y are parallel, which means that their direction is the same or the exact opposite.
 
bool scifir::orthogonal (const vector_unit_3d &x, const vector_unit_3d &y)
 Checks if two vectors x and y are orthogonal, that's, if they have 90 degrees between them.
 
scifir::vector_unit_3d operator* (const scifir::scalar_unit &x, const scifir::vector_unit_3d &y)
 It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
 
bool operator!= (const scifir::vector_unit_3d &x, const scifir::vector_unit_3d &y)
 Comparison operator. Two vector_unit_3d are not equal if their value, dimensions, theta or phi are different.
 
bool operator== (const scifir::vector_unit_3d &x, const string &init_vector_3d)
 Returns true if x is equal to the vector_unit_3d 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_3d &x, const string &init_vector_3d)
 Returns true if x is not equal to the vector_unit_3d 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_3d, const scifir::vector_unit_3d &y)
 Returns true if x is equal to the vector_unit_3d 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_3d, const scifir::vector_unit_3d &y)
 Returns true if x is not equal to the vector_unit_3d 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_3d &y)
 Concatenates the string representation of the vector_unit_3d y to the string x.
 
string operator+ (const string &x, const scifir::vector_unit_3d &y)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.
 
string operator+ (const scifir::vector_unit_3d &y, const string &x)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.
 
ostream & operator<< (ostream &os, const scifir::vector_unit_3d &x)
 Adds the string representation of the vector_unit_3d x to an output stream os.
 
istream & operator>> (istream &is, scifir::vector_unit_3d &x)
 Allows that an istream initializes by string a vector_unit_3d x.
 

Function Documentation

◆ operator!=() [1/3]

bool operator!= ( const scifir::vector_unit_3d x,
const scifir::vector_unit_3d y 
)

Comparison operator. Two vector_unit_3d are not equal if their value, dimensions, theta or phi are different.

Definition at line 539 of file vector_unit_3d.cpp.

540{
541 return !(x == y);
542}

◆ operator!=() [2/3]

bool operator!= ( const scifir::vector_unit_3d x,
const string &  init_vector_3d 
)

Returns true if x is not equal to the vector_unit_3d 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 550 of file vector_unit_3d.cpp.

551{
552 return !(x == init_vector_3d);
553}

◆ operator!=() [3/3]

bool operator!= ( const string &  init_vector_3d,
const scifir::vector_unit_3d y 
)

Returns true if x is not equal to the vector_unit_3d 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 561 of file vector_unit_3d.cpp.

562{
563 return !(init_vector_3d == y);
564}

◆ operator*()

scifir::vector_unit_3d operator* ( const scifir::scalar_unit x,
const scifir::vector_unit_3d y 
)

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

Definition at line 532 of file vector_unit_3d.cpp.

533{
534 long double new_value = x.get_value() * y.get_value();
535 vector<scifir::dimension> new_dimensions = multiply_dimensions(x.get_dimensions(), y.get_dimensions(),new_value);
536 return scifir::vector_unit_3d(float(new_value), new_dimensions, y.theta, y.phi);
537}
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
const float & get_value() const
Read-only getter of the value.
Class that creates a vector unit in 3D. The vector is in spherical coordinates with a value and dimen...
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< 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+() [1/2]

string operator+ ( const scifir::vector_unit_3d y,
const string &  x 
)

Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.

Definition at line 581 of file vector_unit_3d.cpp.

582{
583 ostringstream output;
584 output << y;
585 output << x;
586 return output.str();
587}

◆ operator+() [2/2]

string operator+ ( const string &  x,
const scifir::vector_unit_3d y 
)

Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.

Definition at line 573 of file vector_unit_3d.cpp.

574{
575 ostringstream output;
576 output << x;
577 output << y;
578 return output.str();
579}

◆ operator+=()

void operator+= ( string &  x,
const scifir::vector_unit_3d y 
)

Concatenates the string representation of the vector_unit_3d y to the string x.

Definition at line 566 of file vector_unit_3d.cpp.

567{
568 ostringstream output;
569 output << y;
570 x += output.str();
571}

◆ operator<<()

ostream & operator<< ( ostream &  os,
const scifir::vector_unit_3d x 
)

Adds the string representation of the vector_unit_3d x to an output stream os.

Definition at line 589 of file vector_unit_3d.cpp.

590{
591 return os << to_string(x);
592}
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
Definition aid.cpp:582

◆ operator==() [1/2]

bool operator== ( const scifir::vector_unit_3d x,
const string &  init_vector_3d 
)

Returns true if x is equal to the vector_unit_3d 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 544 of file vector_unit_3d.cpp.

545{
546 scifir::vector_unit_3d y(init_vector_3d);
547 return (x == y);
548}

◆ operator==() [2/2]

bool operator== ( const string &  init_vector_3d,
const scifir::vector_unit_3d y 
)

Returns true if x is equal to the vector_unit_3d 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 555 of file vector_unit_3d.cpp.

556{
557 scifir::vector_unit_3d x(init_vector_3d);
558 return (x == y);
559}

◆ operator>>()

istream & operator>> ( istream &  is,
scifir::vector_unit_3d x 
)

Allows that an istream initializes by string a vector_unit_3d x.

#endif // SCIFIR_UNITS_UNITS_VECTOR_UNIT_3D_HPP_INCLUDED

Definition at line 594 of file vector_unit_3d.cpp.

595{
596 char a[256];
597 is.getline(a, 256);
598 string b(a);
599 boost::trim(b);
601 return is;
602}