Arcade Shooter
MathUtil.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
17  class Math
18  {
19 
20  public:
21 
22  static const float PI;
23  static const float PI_OVER2;
24  static const float PI_OVER4;
25  static const float INVERSE_PI;
26  static const float NORMALIZE_PI_OVER4;
27  static const float INVERSE_180;
35  static float Lerp(float start, float end, float value);
36 
41  static int GetRandomInt(const int min = 0, const int max = RAND_MAX);
42 
45  static float GetRandomFloat() { return ((float)rand() / RAND_MAX); }
46 
51  static float Min(const float value1, const float value2);
52 
57  static float Max(const float value1, const float value2);
58 
62  static float Abs(const float value);
63 
69  static float Clamp(const float min, const float max, const float value);
70 
74  static float ToRadians(const float degrees) { return degrees * PI * INVERSE_180; }
75 
79  static float ToDegrees(const float radians) { return radians * 180 * INVERSE_PI; }
80  };
81 }
static const float PI_OVER2
Represents the value of pi divided by two.
Definition: MathUtil.h:23
static const float PI_OVER4
Represents the value of pi divided by four.
Definition: MathUtil.h:24
static float ToRadians(const float degrees)
Converts degrees to radians.
Definition: MathUtil.h:74
static float GetRandomFloat()
Get a random number between zero and one.
Definition: MathUtil.h:45
Provides commonly used floating point functions and constants.
Definition: MathUtil.h:17
static const float PI
Represents the value of pi.
Definition: MathUtil.h:22
static float Abs(const float value)
Get the absolute value of a number.
Definition: MathUtil.cpp:48
static const float NORMALIZE_PI_OVER4
Represents the value of each component in a pi/4 unit vector.
Definition: MathUtil.h:26
static float ToDegrees(const float radians)
Converts radians to degrees.
Definition: MathUtil.h:79
static const float INVERSE_PI
Represents the value of one divided by pi.
Definition: MathUtil.h:25
static const float INVERSE_180
Represents the value of one divided by 180.
Definition: MathUtil.h:27
static float Min(const float value1, const float value2)
Get the lessor of two numbers.
Definition: MathUtil.cpp:36
static float Clamp(const float min, const float max, const float value)
Restricts a value to be within a specified range.
Definition: MathUtil.cpp:54
static float Max(const float value1, const float value2)
Get the greator of two numbers.
Definition: MathUtil.cpp:42
static float Lerp(float start, float end, float value)
Linearly interpolate between two values.
Definition: MathUtil.cpp:23
static int GetRandomInt(const int min=0, const int max=RAND_MAX)
Get a random integer.
Definition: MathUtil.cpp:31
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14