10 const double pi = 3.1415926536;
16 return static_cast<long>(value);
23 return static_cast<long>(value + 0.5);
25 return static_cast<long>(value - 0.5);
30 double random(
double min,
double max);
36 return (angle - 90) *
pi / 180;
42 return angle * 180 /
pi + 90;
49 return angle *
pi / 180;
55 return angle * 180 /
pi;
70 double angle(
double fromX,
double fromY,
double toX,
double toY,
74 double angleDiff(
double angle1,
double angle2);
101 return clamp(value, min, max);
107 int wrap(
int value,
int min,
int max);
111 float wrap(
float value,
float min,
float max);
115 double wrap(
double value,
double min,
double max);
118 inline double distanceSqr(
double x1,
double y1,
double x2,
double y2)
124 double distance(
double x1,
double y1,
double x2,
double y2);
131 return a * (1.0 - weight) + b * weight;
double normalizeAngle(double angle)
Normalizes an angle to fit into the range [0; 360[.
long trunc(double value)
Truncates the fractional part of a real value.
double distance(double x1, double y1, double x2, double y2)
Returns the distance between two points.
double gosuToRadians(double angle)
Translates between Gosu's angle system (where 0¡ is at the top) and radians (where 0 is at the right)...
T clamp(T value, T min, T max)
Returns min if value is smaller than min, max if value is larger than max and value otherwise...
T square(T value)
Returns value * value.
long round(double value)
Rounds a real value towards the next integer.
T boundBy(T value, T min, T max)
double offsetX(double angle, double radius)
Returns the horizontal distance between the origin and the point to which you would get if you moved ...
double angleDiff(double angle1, double angle2)
Returns the smallest angle that can be added to angle1 to get to angle2 (can be negative if counter-c...
double distanceSqr(double x1, double y1, double x2, double y2)
Returns the square of the distance between two points.
int wrap(int value, int min, int max)
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min...
Color interpolate(Color a, Color b, double weight=0.5)
Interpolates linearly between two colors, with a given weight towards the second color.
double random(double min, double max)
Returns a real value between min (inclusive) and max (exclusive).
double radiansToDegrees(double angle)
Translates between degrees (used by Gosu) and radians, i.e.
double offsetY(double angle, double radius)
Returns the vertical distance between the origin and the point to which you would get if you moved ra...
double degreesToRadians(double angle)
Translates between degrees (used by Gosu) and radians, i.e.
double radiansToGosu(double angle)
Translates between Gosu's angle system (where 0¡ is at the top) and radians (where 0 is at the right)...
double angle(double fromX, double fromY, double toX, double toY, double def=0)
Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards.