Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
MathUtil.cpp
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#include "KatanaEngine.h"
16
17namespace KatanaEngine
18{
19 const float Math::PI = 3.14159265359f;
20 const float Math::PI_OVER2 = Math::PI / 2;
21 const float Math::PI_OVER4 = Math::PI / 4;
22 const float Math::INVERSE_PI = 1.0f / Math::PI;
23 const float Math::NORMALIZE_PI_OVER4 = 0.70710678119f;
24 const float Math::INVERSE_180 = 1.0f / 180;
25
26 float Math::Lerp(float start, float end, float value)
27 {
28 if (value < 0) return start;
29 if (value > 1) return end;
30
31 return start + (end - start) * value;
32 }
33
34 int Math::GetRandomInt(const int min, const int max)
35 {
36 return (rand() % (max - min + 1)) + min;
37 }
38
39 float Math::Min(const float value1, const float value2)
40 {
41 if (value1 < value2) return value1;
42 return value2;
43 }
44
45 float Math::Max(const float value1, const float value2)
46 {
47 if (value1 > value2) return value1;
48 return value2;
49 }
50
51 float Math::Abs(const float value)
52 {
53 if (value < 0) return -value;
54 else return value;
55 }
56
57
58}
static float Max(const float value1, const float value2)
Get the greator of two numbers.
Definition MathUtil.cpp:45
static const float PI_OVER4
Represents the value of pi divided by four.
Definition MathUtil.h:27
static int GetRandomInt(const int min=0, const int max=RAND_MAX)
Get a random integer.
Definition MathUtil.cpp:34
static const float INVERSE_180
Represents the value of one divided by 180.
Definition MathUtil.h:30
static const float PI
Represents the value of pi.
Definition MathUtil.h:25
static float Min(const float value1, const float value2)
Get the lessor of two numbers.
Definition MathUtil.cpp:39
static const float INVERSE_PI
Represents the value of one divided by pi.
Definition MathUtil.h:28
static float Lerp(float start, float end, float value)
Linearly interpolate between two values.
Definition MathUtil.cpp:26
static const float PI_OVER2
Represents the value of pi divided by two.
Definition MathUtil.h:26
static const float NORMALIZE_PI_OVER4
Represents the value of each component in a pi/4 unit vector.
Definition MathUtil.h:29
static float Abs(const float value)
Get the absolute value of a number.
Definition MathUtil.cpp:51
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18