Holds the ratio of 2 positive integers in the form of \((n:m)\). More...
#include <cadex/Drawing/Ratio.hxx>
Public Member Functions | |
Ratio () | |
Default constructor. Initializes with ratio \((1:1)\). | |
Ratio (size_t theNumerator, size_t theDenominator) | |
Constructor. Initializes with user-defined ratio. | |
size_t | Numerator () const |
Returns the numerator of the ratio (i.e. \(n\) from \((n:m)\)). | |
void | SetNumerator (size_t theNumerator) |
Sets the numerator of the ratio (i.e. \(n\) from \((n:m)\)). | |
size_t | Denominator () const |
Returns the denominator of the ratio (i.e. \(m\) from \((n:m)\)). | |
void | SetDenominator (size_t theDenominator) |
Sets the denominator of the ratio (i.e. \(m\) from \((n:m)\)). | |
double | ToDouble () const |
Converts the ratio to double floating-point number. | |
bool | operator== (const Ratio &theOther) const |
Returns true if the ratios are equal. | |
bool | operator!= (const Ratio &theOther) const |
Returns true if the ratios are not equal. | |
Holds the ratio of 2 positive integers in the form of \((n:m)\).
Can be used to define the scale factor in certain situations. The numerator and denominator are not reduced, they are stored as is.
cadex::Drawing::Ratio::Ratio | ( | size_t | theNumerator, |
size_t | theDenominator ) |
Constructor. Initializes with user-defined ratio.
bool cadex::Drawing::Ratio::operator== | ( | const Ratio & | theOther | ) | const |
Returns true if the ratios are equal.
Given 2 ratios \((n:m)\) and \((p:q)\) their equality is tested as equality of rational numbers \(\frac{n}{m}\) and \(\frac{p}{q}\).
void cadex::Drawing::Ratio::SetDenominator | ( | size_t | theDenominator | ) |
Sets the denominator of the ratio (i.e. \(m\) from \((n:m)\)).
void cadex::Drawing::Ratio::SetNumerator | ( | size_t | theNumerator | ) |
Sets the numerator of the ratio (i.e. \(n\) from \((n:m)\)).