Hide menu
Loading...
Searching...
No Matches
cadex::Drawing::Ratio Class Reference

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.
 

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
View::Scale()

Constructor & Destructor Documentation

◆ Ratio()

cadex::Drawing::Ratio::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::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}\).

◆ SetDenominator()

void cadex::Drawing::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::Drawing::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.