1#ifndef SCIFIR_UNITS_COORDINATES_COORDINATES_2D_HPP_INCLUDED
2#define SCIFIR_UNITS_COORDINATES_COORDINATES_2D_HPP_INCLUDED
4#include "../units/base_units.hpp"
5#include "../derived_units/physics_units.hpp"
6#include "../util/types.hpp"
15 template<
typename T = length>
138 out <<
"(" <<
x <<
"," <<
y <<
")";
165 if (values.size() == 2)
239 return float(std::sqrt(std::pow(
x,2) + std::pow(
y,2)));
287 return float(std::sqrt(std::pow(
x,2) + std::pow(
y,2)));
320 if (values.size() == 2)
322 if (values[0] ==
"" or values[1] ==
"")
344 string to_string(
const coordinates_2d<float>& x);
346 template<
typename T,
typename U>
352 float distance(
const coordinates_2d<float>& x,
const coordinates_2d<float>& y);
378 return float(std::sqrt(std::pow(x,2) + std::pow(y,2)));
397template<
typename T,
typename U>
400 if (x.
x == y.
x and x.y == y.y)
410template<
typename T,
typename U>
426 return !(x == init_coordinates_2d);
439 return !(init_coordinates_2d == x);
451 return x + to_string(y);
457 return to_string(x) + y;
463 return os << to_string(x);
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
string display_cartesian() const
void move(const scalar_unit &x_value)
void initialize_from_string(string init_coordinates_2d)
void move(float new_p, const angle &new_theta)
coordinates_2d(float new_p, const angle &new_theta)
coordinates_2d(const string &init_coordinates_2d)
void move(const displacement_2d &x_displacement)
void rotate(const angle &x_angle)
coordinates_2d(const coordinates_2d< float > &x_coordinates)
void set_position(float new_p, const angle &new_theta)
string display_polar() const
coordinates_2d(float new_x, float new_y)
void set_position(float new_x, float new_y)
float distance_to_origin() const
coordinates_2d(coordinates_2d< length >::type coordinates_type, const string &coord1, const string &coord2)
coordinates_2d(coordinates_2d< float > &&x_coordinates)
string display_cartesian() const
void move(float new_x, float new_y)
coordinates_2d(const string &init_coordinates_2d)
void move(const displacement_2d &x_displacement)
static coordinates_2d< T > origin(const coordinates_2d< T > &origin, const coordinates_2d< T > &coordinates)
void rotate(const angle &x_angle)
void move(const scalar_unit &new_x, const scalar_unit &new_y)
coordinates_2d(const coordinates_2d< T > &x_coordinates)
coordinates_2d(coordinates_2d::type coordinates_type, const string &coord1, const string &coord2)
coordinates_2d(coordinates_2d< T > &&x_coordinates)
T distance_to_origin() const
coordinates_2d< T > & operator=(const coordinates_2d< T > &x_coordinates)
string display_cartesian() const
void initialize_from_string(string init_coordinates_2d)
string display_polar() const
coordinates_2d(const scalar_unit &new_x, const scalar_unit &new_y)
coordinates_2d(const scalar_unit &new_p, const angle &new_theta)
void set_position(const scalar_unit &new_p, const angle &new_theta)
void set_position(const scalar_unit &new_x, const scalar_unit &new_y)
void move(const scalar_unit &new_p, const angle &new_theta)
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
void change_dimensions(const string &init_dimensions)
Changes the dimensions to the dimensions specified by the initialization string of dimensions.
string operator+(const string &x, const scifir::coordinates_2d< T > &y)
ostream & operator<<(ostream &os, const scifir::coordinates_2d< T > &x)
bool operator!=(const scifir::coordinates_2d< T > &x, const scifir::coordinates_2d< U > &y)
bool operator==(const scifir::coordinates_2d< T > &x, const scifir::coordinates_2d< U > &y)
void operator+=(string &x, const scifir::coordinates_2d< T > &y)
istream & operator>>(istream &is, scifir::coordinates_2d< T > &x)
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
scalar_unit polar_to_cartesian_2d_x(const scalar_unit &p, const angle &theta)
float cos(const angle &x)
Calculates the cos of angle x. It uses the cos() function of the standard library of C++,...
angle cartesian_2d_to_polar_theta(const scalar_unit &x, scalar_unit y)
scalar_unit pow(const scalar_unit &x, int exponent)
Exponentiates a scalar_unit to some numeric type, the dimensions are also exponentiated.
float atan_degree(float x)
Calculates the atan receiving x in degrees. It uses the atan() function of the standard library of C+...
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
angle atan2(float y, float x)
float distance(const coordinates_1d< float > &x, const coordinates_1d< float > &y)
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit y)
string display_float(const float &value, int number_of_decimals)
scalar_unit polar_to_cartesian_2d_y(const scalar_unit &p, const angle &theta)
float sin(const angle &x)
Calculates the sin of angle x. It uses the sin() function of the standard library of C++,...
angle sqrt(const angle &x)
Calculates the square root of the angle x and returns that new angle.
bool is_angle(const string &init_angle)
Checks if some string is an initialization string of an angle.