Hide menu
Loading...
Searching...
No Matches
cadex::ModelData_Ratio Class Reference

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.
 

Detailed Description

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.

See also
ModelData_DrawingView::Scale()

Constructor & Destructor Documentation

◆ ModelData_Ratio()

cadex::ModelData_Ratio::ModelData_Ratio ( size_t  theNumerator,
size_t  theDenominator 
)

Constructor. Initializes with user-defined ratio.

Warning
0 does not make sense for and should not be passed to either of the parameters.

Member Function Documentation

◆ operator==()

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}\).

◆ SetDenominator()

void cadex::ModelData_Ratio::SetDenominator ( size_t  theDenominator)

Sets the denominator of the ratio (i.e. \(m\) from \((n:m)\)).

Warning
0 does not make sense for and should not be supplied to this parameter.

◆ SetNumerator()

void cadex::ModelData_Ratio::SetNumerator ( size_t  theNumerator)

Sets the numerator of the ratio (i.e. \(n\) from \((n:m)\)).

Warning
0 does not make sense for and should not be supplied to this parameter.