Holds the ratio of 2 positive integers in the form of \((n:m)\). More...
#include <cadex/ModelData_Ratio.hxx>
Public Member Functions | |
__CADEX_EXPORT | ModelData_Ratio () |
Default constructor. Initializes with ratio \((1:1)\). | |
__CADEX_EXPORT | ModelData_Ratio (size_t theNumerator, size_t theDenominator) |
Constructor. Initializes with user-defined ratio. | |
__CADEX_EXPORT size_t | Numerator () const |
Returns the numerator of the ratio (i.e. \(n\) from \((n:m)\)). | |
__CADEX_EXPORT void | SetNumerator (size_t theNumerator) |
Sets the numerator of the ratio (i.e. \(n\) from \((n:m)\)). | |
__CADEX_EXPORT size_t | Denominator () const |
Returns the denominator of the ratio (i.e. \(m\) from \((n:m)\)). | |
__CADEX_EXPORT void | SetDenominator (size_t theDenominator) |
Sets the denominator of the ratio (i.e. \(m\) from \((n:m)\)). | |
__CADEX_EXPORT double | ToDouble () const |
Converts the ratio to double floating-point number. | |
__CADEX_EXPORT bool | operator== (const ModelData_Ratio &theOther) const |
Returns true if the ratios are equal. | |
__CADEX_EXPORT bool | operator!= (const ModelData_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::ModelData_Ratio::ModelData_Ratio | ( | size_t | theNumerator, |
size_t | theDenominator | ||
) |
Constructor. Initializes with user-defined ratio.
bool cadex::ModelData_Ratio::operator== | ( | const ModelData_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::ModelData_Ratio::SetDenominator | ( | size_t | theDenominator | ) |
Sets the denominator of the ratio (i.e. \(m\) from \((n:m)\)).
void cadex::ModelData_Ratio::SetNumerator | ( | size_t | theNumerator | ) |
Sets the numerator of the ratio (i.e. \(n\) from \((n:m)\)).