NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
math.hpp
1#pragma once
2
3#include <lib/nw4r/math/vec.hpp>
4#include <lib/MSL_C/math.h>
5
6namespace EGG {
8 template <class T>
9 class Math {
10 public:
11 static T sqrt(T v);
12
13 static T abs(T v) {
14 return v < 0 ? -v : v;
15 }
16 };
17
18 template <>
19 float Math<float>::abs(float v) {
20 return fabs(v);
21 }
22
23 typedef Math<float> Mathf;
24
26 class Vector2f : public nw4r::math::VEC2 {
27 public:
30
31 ~Vector2f() {}
32
34 Vector2f(f32 fx, f32 fy) { set(fx, fy); }
35
37 Vector2f(const Vector2f &v) { set(v.x, v.y); }
38
39 void set(float x, float y) {
40 this->x = x;
41 this->y = y;
42 }
43
44 float normalise();
45
47 float getLength() const { return EGG::Mathf::sqrt(x * x + y * y); }
48 };
49}
A two-dimensional floating point vector.
Definition math.hpp:26
Vector2f()
Constructs an empty vector.
Definition math.hpp:29
float getLength() const
Gets the length of the vector.
Definition math.hpp:47
Vector2f(f32 fx, f32 fy)
Constructs a vector from two floating point values.
Definition math.hpp:34
Vector2f(const Vector2f &v)
Constructs a new vector from an existing vector.
Definition math.hpp:37
double fabs(double x)
Returns the absolute value of x.
Definition math.h:15