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
angle.cpp File Reference
#include "./angle.hpp"
#include "../util/types.hpp"
#include "boost/algorithm/string.hpp"
#include "unicode/unistr.h"
#include "unicode/uchar.h"
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
Include dependency graph for angle.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

string scifir::to_string (const angle &x)
 Converts an angle to their string representation.
 
bool scifir::is_angle (const string &init_angle)
 Checks if some string is an initialization string of an angle.
 
bool scifir::parallel (const angle &x, const angle &y)
 Checks if two angles in a 2D correspond to parallel lines (or parallel vectors).
 
bool scifir::orthogonal (const angle &x, const angle &y)
 Checks if two angles in a 2D correspond to orthogonal lines (or orthogonal vectors).
 
angle scifir::sqrt (const angle &x)
 Calculates the square root of the angle x and returns that new angle.
 
angle scifir::sqrt_nth (const angle &x, int index)
 Calculates the nth root of the angle x and returns that new angle.
 
float scifir::sin (const angle &x)
 Calculates the sin of angle x. It uses the sin() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
float scifir::cos (const angle &x)
 Calculates the cos of angle x. It uses the cos() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
float scifir::tan (const angle &x)
 Calculates the tan of angle x. It uses the tan() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
angle scifir::asin (float x)
 Calculates the asin of some value x and returns the result as angle in degrees.
 
angle scifir::acos (float x)
 Calculates the acos of some value x and returns the result as angle in degrees.
 
angle scifir::atan (float x)
 Calculates the atan of some value x and returns the result as angle in degrees.
 
angle scifir::atan2 (float y, float x)
 
float scifir::sinh (const angle &x)
 Calculates the sinh of angle x. It uses the sinh() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
float scifir::cosh (const angle &x)
 Calculates the cosh of angle x. It uses the cosh() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
float scifir::tanh (const angle &x)
 Calculates the tanh of angle x. It uses the tanh() function of the standard library of C++, the difference is that angle is in degrees, not in radians.
 
angle scifir::asinh (float x)
 Calculates the asinh of some value x and returns the result as angle in degrees.
 
angle scifir::acosh (float x)
 Calculates the acosh of some value x and returns the result as angle in degrees.
 
angle scifir::atanh (float x)
 Calculates the atanh of some value x and returns the result as angle in degrees.
 
bool operator== (const scifir::angle &x, const scifir::angle &y)
 Checks if two angles have equal value.
 
bool operator!= (const scifir::angle &x, const scifir::angle &y)
 Checks if two angles have not equal value.
 
bool operator< (const scifir::angle &x, const scifir::angle &y)
 Checks if the value of angle x is lower than the value of angle y.
 
bool operator> (const scifir::angle &x, const scifir::angle &y)
 Checks if the value of angle x is greather than the value of angle y.
 
bool operator<= (const scifir::angle &x, const scifir::angle &y)
 Checks if the value of angle x is lower or equal than the value of angle y.
 
bool operator>= (const scifir::angle &x, const scifir::angle &y)
 Checks if the value of angle x is equal or greather than the value of angle y.
 
bool operator== (const scifir::angle &x, const string &init_angle)
 Checks if the angle x is equal than the angle initialized with the initialization string of angle init_angle.
 
bool operator!= (const scifir::angle &x, const string &init_angle)
 Checks if the angle x is not equal than the angle initialized with the initialization string of angle init_angle.
 
bool operator== (const string &init_angle, const scifir::angle &x)
 Checks if the angle x is equal than the angle initialized with the initialization string of angle init_angle.
 
bool operator!= (const string &init_angle, const scifir::angle &x)
 Checks if the angle x is not equal than the angle initialized with the initialization string of angle init_angle.
 
void operator+= (string &x, const scifir::angle &y)
 Concatenates to string x the string representation of angle y.
 
string operator+ (const string &x, const scifir::angle &y)
 Concatenates the string x with the string representation of angle y into a new string.
 
string operator+ (const scifir::angle &y, const string &x)
 Concatenates the string x with the string representation of angle y into a new string.
 
ostream & operator<< (ostream &os, const scifir::angle &x)
 Sends the string representation of angle x to an output stream.
 
istream & operator>> (istream &is, scifir::angle &x)
 Initializes an angle with an initialization string obtained from an input stream.
 

Function Documentation

◆ operator!=() [1/3]

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

Checks if two angles have not equal value.

Definition at line 504 of file angle.cpp.

505{
506 return !(x == y);
507}

◆ operator!=() [2/3]

bool operator!= ( const scifir::angle x,
const string &  init_angle 
)

Checks if the angle x is not equal than the angle initialized with the initialization string of angle init_angle.

Definition at line 549 of file angle.cpp.

550{
551 return !(x == init_angle);
552}

◆ operator!=() [3/3]

bool operator!= ( const string &  init_angle,
const scifir::angle x 
)

Checks if the angle x is not equal than the angle initialized with the initialization string of angle init_angle.

Definition at line 560 of file angle.cpp.

561{
562 return !(init_angle == x);
563}

◆ operator+() [1/2]

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

Concatenates the string x with the string representation of angle y into a new string.

Definition at line 580 of file angle.cpp.

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

◆ operator+() [2/2]

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

Concatenates the string x with the string representation of angle y into a new string.

Definition at line 572 of file angle.cpp.

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

◆ operator+=()

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

Concatenates to string x the string representation of angle y.

Definition at line 565 of file angle.cpp.

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

◆ operator<()

bool operator< ( const scifir::angle x,
const scifir::angle y 
)

Checks if the value of angle x is lower than the value of angle y.

Definition at line 509 of file angle.cpp.

510{
511 if(x.get_value() < y.get_value())
512 {
513 return true;
514 }
515 else
516 {
517 return false;
518 }
519}
const float & get_value() const
Gets the value of the angle, in degrees.
Definition angle.hpp:102

◆ operator<<()

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

Sends the string representation of angle x to an output stream.

Definition at line 588 of file angle.cpp.

589{
590 return os << to_string(x);
591}
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<=()

bool operator<= ( const scifir::angle x,
const scifir::angle y 
)

Checks if the value of angle x is lower or equal than the value of angle y.

Definition at line 533 of file angle.cpp.

534{
535 return !(x > y);
536}

◆ operator==() [1/3]

bool operator== ( const scifir::angle x,
const scifir::angle y 
)

Checks if two angles have equal value.

Definition at line 492 of file angle.cpp.

493{
494 if(x.get_value() == y.get_value())
495 {
496 return true;
497 }
498 else
499 {
500 return false;
501 }
502}

◆ operator==() [2/3]

bool operator== ( const scifir::angle x,
const string &  init_angle 
)

Checks if the angle x is equal than the angle initialized with the initialization string of angle init_angle.

Definition at line 543 of file angle.cpp.

544{
545 scifir::angle y = scifir::angle(init_angle);
546 return (x == y);
547}
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
Definition angle.hpp:77

◆ operator==() [3/3]

bool operator== ( const string &  init_angle,
const scifir::angle x 
)

Checks if the angle x is equal than the angle initialized with the initialization string of angle init_angle.

Definition at line 554 of file angle.cpp.

555{
556 scifir::angle y = scifir::angle(init_angle);
557 return (x == y);
558}

◆ operator>()

bool operator> ( const scifir::angle x,
const scifir::angle y 
)

Checks if the value of angle x is greather than the value of angle y.

Definition at line 521 of file angle.cpp.

522{
523 if(x.get_value() > y.get_value())
524 {
525 return true;
526 }
527 else
528 {
529 return false;
530 }
531}

◆ operator>=()

bool operator>= ( const scifir::angle x,
const scifir::angle y 
)

Checks if the value of angle x is equal or greather than the value of angle y.

Definition at line 538 of file angle.cpp.

539{
540 return !(x < y);
541}

◆ operator>>()

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

Initializes an angle with an initialization string obtained from an input stream.

Definition at line 593 of file angle.cpp.

594{
595 char a[256];
596 is.getline(a, 256);
597 string b(a);
598 boost::trim(b);
599 x = scifir::angle(b);
600 return is;
601}