From 0c39051ba80f04b1177833a006f2d442a7170b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 3 Dec 2020 17:11:43 +0100 Subject: add initial files l8 --- labb8/lib/StanfordCPPLib/gmath.h | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 labb8/lib/StanfordCPPLib/gmath.h (limited to 'labb8/lib/StanfordCPPLib/gmath.h') diff --git a/labb8/lib/StanfordCPPLib/gmath.h b/labb8/lib/StanfordCPPLib/gmath.h new file mode 100755 index 0000000..7dc8aab --- /dev/null +++ b/labb8/lib/StanfordCPPLib/gmath.h @@ -0,0 +1,104 @@ +/* + * File: gmath.h + * ------------- + * This file exports several functions for working with graphical + * geometry along with the mathematical constants PI + * and E. + */ + +#ifndef _gmath_h +#define _gmath_h + +#include "gtypes.h" + +/* + * Constant: PI + * ------------ + * The mathematical constant pi, which is the ratio of the circumference + * of a circle to its diameter. + */ + +extern const double PI; + +/* + * Constant: E + * ----------- + * The mathematical constant e, which is the base of natural logarithms. + */ + +extern const double E; + +/* + * Function: sinDegrees + * Usage: double sine = sinDegrees(angle); + * --------------------------------------- + * Returns the trigonometric sine of angle, which is + * expressed in degrees. + */ + +double sinDegrees(double angle); + +/* + * Function: cosDegrees + * Usage: double cosine = cosDegrees(angle); + * ----------------------------------------- + * Returns the trigonometric cosine of angle, which is + * expressed in degrees. + */ + +double cosDegrees(double angle); + +/* + * Function: tanDegrees + * Usage: double tangent = tanDegrees(angle); + * ------------------------------------------ + * Returns the trigonometric tangent of angle, which is + * expressed in degrees. + */ + +double tanDegrees(double angle); + +/* + * Function: toDegrees + * Usage: double degrees = toDegrees(radians); + * ------------------------------------------- + * Converts an angle from radians to degrees. + */ + +double toDegrees(double radians); + +/* + * Function: toRadians + * Usage: double radians = toRadians(degrees); + * ------------------------------------------- + * Converts an angle from degrees to radians. + */ + +double toRadians(double degrees); + +/* + * Function: vectorDistance + * Usage: double r = vectorDistance(pt); + * double r = vectorDistance(x, y); + * --------------------------------------- + * Computes the distance between the origin and the specified point. + */ + +double vectorDistance(const GPoint & pt); +double vectorDistance(double x, double y); + +/* + * Function: vectorAngle + * Usage: double angle = vectorAngle(pt); + * double angle = vectorAngle(x, 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. + */ + +double vectorAngle(const GPoint & pt); +double vectorAngle(double x, double y); + +#endif -- cgit v1.2.1