SGL
Functions | Variables
sgl::math Namespace Reference

Functions

double cosDegrees(double angle)
 Returns the trigonometric cosine of angle, which is expressed in degrees. More...
 
int countDigits(int n, int base)
 
template<typename T >
bool floatingPointEqual(T f1, T f2, T tolerance)
 Returns true if the two given floating-point numbers are "equal" to each other, within a given tolerance. More...
 
template<typename T >
bool floatingPointEqual(T f1, T f2)
 Returns true if the two given floating-point numbers are "equal" to each other. More...
 
template<typename T >
bool floatingPointEqual(T f1, int f2)
 Returns true if the given floating-point number is "equal" to the given integer. More...
 
template<typename T >
bool floatingPointEqual(int f1, T f2)
 Returns true if the given floating-point number is "equal" to the given integer. More...
 
template<typename T >
bool floatingPointEqual(T f1, long int f2)
 Returns true if the given floating-point number is "equal" to the given integer. More...
 
template<typename T >
bool floatingPointEqual(long int f1, T f2)
 Returns true if the given floating-point number is "equal" to the given integer. More...
 
double sinDegrees(double angle)
 Returns the trigonometric sine of angle, which is expressed in degrees. More...
 
double tanDegrees(double angle)
 Returns the trigonometric tangent of angle, which is expressed in degrees. More...
 
double toDegrees(double radians)
 Converts an angle from radians to degrees. More...
 
double toRadians(double degrees)
 Converts an angle from degrees to radians. More...
 
double vectorAngle(double x, double y)
 Returns the angle in degrees from the origin to the specified point. More...
 
double vectorAngle(const ::sgl::GPoint &pt)
 Returns the angle in degrees from the origin to the specified point. More...
 
double vectorDistance(double x, double y)
 Computes the distance between the origin and the specified point. More...
 
double vectorDistance(const ::sgl::GPoint &pt)
 Computes the distance between the origin and the specified point. More...
 

Variables

const double E = 2.71828182845904523536
 

Constant: E

The mathematical constant e, which is the base of natural logarithms. More...
 
const double PI = 3.14159265358979323846
 The mathematical constant pi, which is the ratio of the circumference of a circle to its diameter. More...
 

Function Documentation

◆ cosDegrees()

double cosDegrees ( double  angle)

Returns the trigonometric cosine of angle, which is expressed in degrees.

◆ countDigits()

int countDigits ( int  n,
int  base 
)

◆ floatingPointEqual() [1/6]

bool sgl::math::floatingPointEqual ( f1,
f2,
tolerance 
)

Returns true if the two given floating-point numbers are "equal" to each other, within a given tolerance.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ floatingPointEqual() [2/6]

bool sgl::math::floatingPointEqual ( f1,
f2 
)

Returns true if the two given floating-point numbers are "equal" to each other.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ floatingPointEqual() [3/6]

bool sgl::math::floatingPointEqual ( f1,
int  f2 
)

Returns true if the given floating-point number is "equal" to the given integer.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ floatingPointEqual() [4/6]

bool sgl::math::floatingPointEqual ( int  f1,
f2 
)

Returns true if the given floating-point number is "equal" to the given integer.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ floatingPointEqual() [5/6]

bool sgl::math::floatingPointEqual ( f1,
long int  f2 
)

Returns true if the given floating-point number is "equal" to the given integer.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ floatingPointEqual() [6/6]

bool sgl::math::floatingPointEqual ( long int  f1,
f2 
)

Returns true if the given floating-point number is "equal" to the given integer.

Floating-point equality is tricky because of round-off errors, which can cause the numbers to be nearly the same but not identical.

See also: http://stackoverflow.com/questions/4548004/how-to-correctly-and-standardly-compare-floats

◆ sinDegrees()

double sinDegrees ( double  angle)

Returns the trigonometric sine of angle, which is expressed in degrees.

◆ tanDegrees()

double tanDegrees ( double  angle)

Returns the trigonometric tangent of angle, which is expressed in degrees.

◆ toDegrees()

double toDegrees ( double  radians)

Converts an angle from radians to degrees.

◆ toRadians()

double toRadians ( double  degrees)

Converts an angle from degrees to radians.

◆ vectorAngle() [1/2]

double vectorAngle ( double  x,
double  y 
)

Returns the angle in degrees from the origin to the specified point.

This function takes account of the fact that the graphics coordinate system is flipped in the y direction from the traditional Cartesian plane.

◆ vectorAngle() [2/2]

double vectorAngle ( const ::sgl::GPoint pt)

Returns the angle in degrees from the origin to the specified point.

This function takes account of the fact that the graphics coordinate system is flipped in the y direction from the traditional Cartesian plane.

◆ vectorDistance() [1/2]

double vectorDistance ( double  x,
double  y 
)

Computes the distance between the origin and the specified point.

◆ vectorDistance() [2/2]

double vectorDistance ( const ::sgl::GPoint pt)

Computes the distance between the origin and the specified point.

Variable Documentation

◆ E

const double E = 2.71828182845904523536

Constant: E

The mathematical constant e, which is the base of natural logarithms.

◆ PI

const double PI = 3.14159265358979323846

The mathematical constant pi, which is the ratio of the circumference of a circle to its diameter.