`gmath.h`

`PI`

and `E`

.
Constants | |

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

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

Functions | |

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

n, base) | Returns the number of digits in the given number represented in the given base. |

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

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

radians) | Converts an angle from radians to degrees. |

degrees) | Converts an angle from degrees to radians. |

pt)vectorAngle( x, y) | Returns the angle in degrees from the origin to the specified point. |

pt)vectorDistance( x, y) | Computes the distance between the origin and the specified point. |

int countDigits(int n, int base = 10);

Returns the number of digits in the given integer in the given base.
Defaults to base-10, decimal.
For example:

`countDigits(3456)`

returns 4.`countDigits(0)`

returns 1.`countDigits(-778)`

returns 3.`countDigits(16, 2)`

returns 5.

Throws an error if base is 0 or negative.

Usage:

int digits = countDigits(16, 2);

double sinDegrees(double angle);

Returns the trigonometric sine of

`angle`

, which is
expressed in degrees.
Usage:

double sine = sinDegrees(angle);

double cosDegrees(double angle);

Returns the trigonometric cosine of

`angle`

, which is
expressed in degrees.
Usage:

double cosine = cosDegrees(angle);

double tanDegrees(double angle);

Returns the trigonometric tangent of

`angle`

, which is
expressed in degrees.
Usage:

double tangent = tanDegrees(angle);

double toDegrees(double radians);

Converts an angle from radians to degrees.

Usage:

double degrees = toDegrees(radians);

double toRadians(double degrees);

Converts an angle from degrees to radians.

Usage:

double radians = toRadians(degrees);

double vectorDistance(const GPoint & pt); double vectorDistance(double x, double y);

Computes the distance between the origin and the specified point.

Usage:

double r = vectorDistance(pt); double r = vectorDistance(x, y);

double vectorAngle(const GPoint & pt); 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.

Usage:

double angle = vectorAngle(pt); double angle = vectorAngle(x, y);