LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
math.h
1 #ifndef MATH_H
2 #define MATH_H
3 
4 #include <memory>
5 #include "base.h"
6 
8 
11 class Math {
12 public:
14  enum { UP, DOWN, LEFT, RIGHT };
21  static float Distance(const Vector2f &a, const Vector2f &b);
29  static float Clamp(const float x, const float min, const float max);
35  static float Magnitude(const Vector2f &v);
41  static Vector2f Normalize(const Vector2f &v);
49  static Vector2f Lerp(const Vector2f &start, const Vector2f &end, float percent);
55  static Vector2f ForwardVector(float degrees);
65  static int RectNearRect(const Rectf &a, const Rectf &b, int tolerance = 0);
72  static bool CheckCollision(const Rectf &a, const Rectf &b);
80  static bool CheckCollision(const Vector2f &p, const Rectf &r);
87  static Vector2f ToSceneSpace(const std::weak_ptr<Camera> cam, const Vector2f &v);
94  static Rectf ToSceneSpace(const std::weak_ptr<Camera> cam, const Rectf &r);
101  static Vector2f FromSceneSpace(const std::weak_ptr<Camera> cam, const Vector2f &v);
108  static Rectf FromSceneSpace(const std::weak_ptr<Camera> cam, const Rectf &r);
109 };
110 
111 #endif