Creation of physics project
[physics.git] / src / mathw.cpp
CommitLineData
ad9f1fb6
PG
1#include "mathw.h"
2
3
4/// ***** Private Varibles *****
5
6const float PI = 3.141592653;
7
8
9/// ***** Public Methods *****
10
11int mod(int x, int y)
12{
13 return x % y + (x < 0 ? y : 0);
14}
15
16float radsToA(float rads)
17{
18 return ftofix(rads * 128/PI);
19}
20
21float atanA(float c)
22{
23 return radsToA(atan(c)) + itofix(64);
24}
25
26float atan2A(float y, float x)
27{
28 return radsToA(atan2(y,x)) + itofix(64);
29}
30
31/// Vector2 Math
32
33Vector2 perp(const Vector2& vec)
34{
35 return Vector2(-vec.y, vec.x);
36}
37
38float dot(const Vector2& vec1, const Vector2& vec2)
39{
40 return vec1.x * vec2.x + vec1.y * vec2.y;
41}
42
43//TODO float Vector2::projectionCoeff(const Vector2* vec) const;
44//TODO Vector2* Vector2::projection(const Vector2* vec) const;
45