Просмотр исходного кода

Switch math library to underscore_notation

taylor001 13 лет назад
Родитель
Сommit
03dc08ada2

+ 16 - 16
src/core/math/Angles.cpp

@@ -53,7 +53,7 @@ Angles::Angles(real h, real p, real b) : heading(h), pitch(p), bank(b)
 }
 
 //-----------------------------------------------------------------------------
-Str Angles::ToStr() const
+Str Angles::to_str() const
 {
 	Str tmp;
 
@@ -63,16 +63,16 @@ Str Angles::ToStr() const
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Angles::ToMat3() const
+Mat3 Angles::to_mat3() const
 {
 	Mat3 tmp;
 
-	real sh = Math::Sin(heading);
-	real ch = Math::Cos(heading);
-	real sp = Math::Sin(pitch);
-	real cp = Math::Cos(pitch);
-	real sb = Math::Sin(bank);
-	real cb = Math::Cos(bank);
+	real sh = math::sin(heading);
+	real ch = math::cos(heading);
+	real sp = math::sin(pitch);
+	real cp = math::cos(pitch);
+	real sb = math::sin(bank);
+	real cb = math::cos(bank);
 
 	tmp.m[0] = ch * cb + sh * sp * sb;
 	tmp.m[1] = sb * cp;
@@ -88,16 +88,16 @@ Mat3 Angles::ToMat3() const
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Angles::ToMat4() const
+Mat4 Angles::to_mat4() const
 {
 	Mat4 tmp;
 
-	real sh = Math::Sin(heading);
-	real ch = Math::Cos(heading);
-	real sp = Math::Sin(pitch);
-	real cp = Math::Cos(pitch);
-	real sb = Math::Sin(bank);
-	real cb = Math::Cos(bank);
+	real sh = math::sin(heading);
+	real ch = math::cos(heading);
+	real sp = math::sin(pitch);
+	real cp = math::cos(pitch);
+	real sb = math::sin(bank);
+	real cb = math::cos(bank);
 
 	tmp.m[0] = ch * cb + sh * sp * sb;
 	tmp.m[1] = sb * cp;
@@ -120,7 +120,7 @@ Mat4 Angles::ToMat4() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Angles::ToQuat() const
+Quat Angles::to_quat() const
 {
 	Quat h(heading, Vec3(0.0, 1.0, 0.0));
 	Quat p(pitch, Vec3(1.0, 0.0, 0.0));

+ 4 - 4
src/core/math/Angles.h

@@ -53,10 +53,10 @@ public:
 							Angles(real h, real p, real b);	//!< Construct from three values
 
 
-	Str						ToStr() const;					//!< Returns a Str containing the angles' components
-	Mat3					ToMat3() const;					//!< Returns an equivalent Mat3 representation.
-	Mat4					ToMat4() const;					//!< Returns an equivalent Mat4 representation.
-	Quat					ToQuat() const;					//!< Returns an equivalent Quat representation.
+	Str						to_str() const;					//!< Returns a Str containing the angles' components
+	Mat3					to_mat3() const;					//!< Returns an equivalent Mat3 representation.
+	Mat4					to_mat4() const;					//!< Returns an equivalent Mat4 representation.
+	Quat					to_quat() const;					//!< Returns an equivalent Quat representation.
 
 	static const Angles		ZERO;
 };

+ 25 - 25
src/core/math/Color4.h

@@ -60,10 +60,10 @@ public:
 	explicit				Color4(float c[4]);							//!< Construct from four values
 	explicit				Color4(uint rgba);							//!< Construct from 32-bit integer (red at MSB, alpha at LSB)
 
-	uint					GetAsRGB() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order, alpha assumed = 255)
-	uint					GetAsBGR() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order, alpha assumed = 255)
-	uint					GetAsRGBA() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order)
-	uint					GetAsABGR() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order)
+	uint					get_as_rgb() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order, alpha assumed = 255)
+	uint					get_as_bgr() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order, alpha assumed = 255)
+	uint					get_as_rgba() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order)
+	uint					get_as_abgr() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order)
 
 	float					operator[](uint i) const;					//!< Random access by index
 	float&					operator[](uint i);							//!< Random access by index
@@ -80,9 +80,9 @@ public:
 	bool					operator==(const Color4& other) const;		//!< Equality operator
 	bool					operator!=(const Color4& other) const;		//!< Disequality operator
 
-	float*					ToFloatPtr();								//!< Returns the pointer to the color's data.
-	const float*			ToFloatPtr() const;							//!< Returns the pointer to the color's data.
-	Str						ToStr() const;								//!< Returns a Str containing the colors' components.
+	float*					to_float_ptr();								//!< Returns the pointer to the color's data.
+	const float*			to_float_ptr() const;							//!< Returns the pointer to the color's data.
+	Str						to_str() const;								//!< Returns a Str containing the colors' components.
 
 	// SVG 1.0 color names
 	static const Color4		ALICEBLUE;
@@ -261,9 +261,9 @@ inline Color4::Color4(float r, float g, float b)
 //-----------------------------------------------------------------------------
 inline Color4::Color4(int r, int g, int b)
 {
-	this->r = r * Math::ONE_OVER_255;
-	this->g = g * Math::ONE_OVER_255;
-	this->b = b * Math::ONE_OVER_255;
+	this->r = r * math::ONE_OVER_255;
+	this->g = g * math::ONE_OVER_255;
+	this->b = b * math::ONE_OVER_255;
 	this->a = 1.0f;
 }
 
@@ -279,10 +279,10 @@ inline Color4::Color4(float r, float g, float b, float a)
 //-----------------------------------------------------------------------------
 inline Color4::Color4(int r, int g, int b, int a)
 {
-	this->r = r * Math::ONE_OVER_255;
-	this->g = g * Math::ONE_OVER_255;
-	this->b = b * Math::ONE_OVER_255;
-	this->a = a * Math::ONE_OVER_255;
+	this->r = r * math::ONE_OVER_255;
+	this->g = g * math::ONE_OVER_255;
+	this->b = b * math::ONE_OVER_255;
+	this->a = a * math::ONE_OVER_255;
 }
 
 //-----------------------------------------------------------------------------
@@ -297,26 +297,26 @@ inline Color4::Color4(float c[4])
 //-----------------------------------------------------------------------------
 inline Color4::Color4(uint rgba)
 {
-	r = Math::ONE_OVER_255 * ((rgba & 0xFF000000) >> 24);
-	g = Math::ONE_OVER_255 * ((rgba & 0x00FF0000) >> 16);
-	b = Math::ONE_OVER_255 * ((rgba & 0x0000FF00) >> 8);
-	a = Math::ONE_OVER_255 * (rgba & 0x000000FF);
+	r = math::ONE_OVER_255 * ((rgba & 0xFF000000) >> 24);
+	g = math::ONE_OVER_255 * ((rgba & 0x00FF0000) >> 16);
+	b = math::ONE_OVER_255 * ((rgba & 0x0000FF00) >> 8);
+	a = math::ONE_OVER_255 * (rgba & 0x000000FF);
 }
 
 //-----------------------------------------------------------------------------
-inline float* Color4::ToFloatPtr()
+inline float* Color4::to_float_ptr()
 {
 	return &r;
 }
 
 //-----------------------------------------------------------------------------
-inline const float* Color4::ToFloatPtr() const
+inline const float* Color4::to_float_ptr() const
 {
 	return &r;
 }
 
 //-----------------------------------------------------------------------------
-inline Str Color4::ToStr() const
+inline Str Color4::to_str() const
 {
 	Str tmp;
 
@@ -326,7 +326,7 @@ inline Str Color4::ToStr() const
 }
 
 //-----------------------------------------------------------------------------
-inline uint Color4::GetAsRGB() const
+inline uint Color4::get_as_rgb() const
 {
 	uint rgba;
 
@@ -339,7 +339,7 @@ inline uint Color4::GetAsRGB() const
 }
 
 //-----------------------------------------------------------------------------
-inline uint Color4::GetAsBGR() const
+inline uint Color4::get_as_bgr() const
 {
 	uint abgr;
 
@@ -352,7 +352,7 @@ inline uint Color4::GetAsBGR() const
 }
 
 //-----------------------------------------------------------------------------
-inline uint Color4::GetAsRGBA() const
+inline uint Color4::get_as_rgba() const
 {
 	uint rgba;
 
@@ -365,7 +365,7 @@ inline uint Color4::GetAsRGBA() const
 }
 
 //-----------------------------------------------------------------------------
-inline uint Color4::GetAsABGR() const
+inline uint Color4::get_as_abgr() const
 {
 	uint abgr;
 

+ 16 - 16
src/core/math/Interpolation.h

@@ -37,7 +37,7 @@ class Interpolation
 public:
 
 							/**
-								Linear interpolation between a pair of values.
+								linear interpolation between a pair of values.
 							@param start
 								The start value
 							@param end
@@ -48,10 +48,10 @@ public:
 								The interpolated value
 							*/
 	template <typename T>
-	static T				Linear(const T& p0, const T& p1, real t);
+	static T				linear(const T& p0, const T& p1, real t);
 
 							/**
-								Cosine interpolation between a pair of values.
+								cosine interpolation between a pair of values.
 							@param start
 								The start value
 							@param end
@@ -62,10 +62,10 @@ public:
 								The interpolated value
 							*/
 	template <typename T>
-	static T				Cosine(const T& p0, const T& p1, real t);
+	static T				cosine(const T& p0, const T& p1, real t);
 
 							/**
-								Cubic interpolation between a pair of values.
+								cubic interpolation between a pair of values.
 							@param start
 								The start value
 							@param end
@@ -76,19 +76,19 @@ public:
 								The interpolated value
 							*/
 	template <typename T>
-	static T				Cubic(const T& p0, const T& p1, real t);
+	static T				cubic(const T& p0, const T& p1, real t);
 
 							/**
-								Bezier interpolation.
+								bezier interpolation.
 							*/
 	template <typename T>
-	static T				Bezier(const T& p1, const T& p2, const T& p3, const T& p4, real t);
+	static T				bezier(const T& p1, const T& p2, const T& p3, const T& p4, real t);
 
 							/**
 								Catmull-Rom spline interpolation.
 							*/
 	template <typename T>
-	static T				CatmullRom(const T& p0, const T& p1, const T& p2, const T& p3, real t);
+	static T				catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t);
 
 private:
 
@@ -98,24 +98,24 @@ private:
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Interpolation::Linear(const T& p0, const T& p1, real t)
+inline T Interpolation::linear(const T& p0, const T& p1, real t)
 {
 	return p0 + (t * (p1 - p0));
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Interpolation::Cosine(const T& p0, const T& p1, real t)
+inline T Interpolation::cosine(const T& p0, const T& p1, real t)
 {
-	real f = t * Math::PI;
-	real g = (1.0 - Math::Cos(f)) * 0.5;
+	real f = t * math::PI;
+	real g = (1.0 - math::cos(f)) * 0.5;
 
 	return p0 + (g * (p1 - p0));
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Interpolation::Cubic(const T& p0, const T& p1, real t)
+inline T Interpolation::cubic(const T& p0, const T& p1, real t)
 {
 	real tt = t * t;
 	real ttt = tt * t;
@@ -125,7 +125,7 @@ inline T Interpolation::Cubic(const T& p0, const T& p1, real t)
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Interpolation::Bezier(const T& p0, const T& p1, const T& p2, const T& p3, real t)
+inline T Interpolation::bezier(const T& p0, const T& p1, const T& p2, const T& p3, real t)
 {
 	real u = 1.0 - t;
 	real tt = t * t ;
@@ -143,7 +143,7 @@ inline T Interpolation::Bezier(const T& p0, const T& p1, const T& p2, const T& p
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Interpolation::CatmullRom(const T& p0, const T& p1, const T& p2, const T& p3, real t)
+inline T Interpolation::catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t)
 {
 	real tt = t * t;
 	real ttt = tt * t;

+ 81 - 81
src/core/math/Intersection.h

@@ -121,8 +121,8 @@ private:
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& distance, Vec3& intersectionPoint)
 {
-	real nd = r.direction.Dot(p.n);
-	real orpn = r.origin.Dot(p.n);
+	real nd = r.direction.dot(p.n);
+	real orpn = r.origin.dot(p.n);
 
 	if (nd < 0.0)
 	{
@@ -142,15 +142,15 @@ inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& dista
 inline bool Intersection::TestRaySphere(const Ray& r, const Sphere& s, real& distance, Vec3& intersectionPoint)
 {
 	Vec3 v = s.c - r.origin;
-	real b = v.Dot(r.direction);
-	real det = (s.r * s.r) - v.Dot(v) + (b * b);
+	real b = v.dot(r.direction);
+	real det = (s.r * s.r) - v.dot(v) + (b * b);
 
 	if (det < 0.0 || b < s.r)
 	{
 		return false;
 	}
 
-	distance = b - Math::Sqrt(det);
+	distance = b - math::sqrt(det);
 	intersectionPoint = r.origin + r.direction * distance;
 
 	return true;
@@ -216,9 +216,9 @@ inline bool Intersection::TestRayBox(const Ray& r, const Box& b, real& distance,
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestRayTriangle(const Ray& r, const Triangle& t, real& distance, Vec3& intersectionPoint)
 {
-	if (Intersection::TestRayPlane(r, t.ToPlane(), distance, intersectionPoint))
+	if (Intersection::TestRayPlane(r, t.to_plane(), distance, intersectionPoint))
 	{
-		if (t.ContainsPoint(intersectionPoint))
+		if (t.contains_point(intersectionPoint))
 		{
 			return true;
 		}
@@ -234,14 +234,14 @@ inline bool Intersection::TestPlane3(const Plane& p1, const Plane& p2, const Pla
 	const Vec3& n2 = p2.n;
 	const Vec3& n3 = p3.n;
 
-	real den = -n1.Cross(n2).Dot(n3);
+	real den = -n1.cross(n2).dot(n3);
 
-	if (Math::Equals(den, (real)0.0))
+	if (math::equals(den, (real)0.0))
 	{
 		return false;
 	}
 
-	Vec3 res = p1.d * n2.Cross(n3) + p2.d * n3.Cross(n1) + p3.d * n1.Cross(n2);
+	Vec3 res = p1.d * n2.cross(n3) + p2.d * n3.cross(n1) + p3.d * n1.cross(n2);
 	ip = res / den;
 
 	return true;
@@ -250,7 +250,7 @@ inline bool Intersection::TestPlane3(const Plane& p1, const Plane& p2, const Pla
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestStaticSpherePlane(const Sphere& s, const Plane& p)
 {
-	if (Math::Abs(p.GetDistanceToPoint(s.c)) < s.r)
+	if (math::abs(p.get_distance_to_point(s.c)) < s.r)
 	{
 		return true;
 	}
@@ -261,7 +261,7 @@ inline bool Intersection::TestStaticSpherePlane(const Sphere& s, const Plane& p)
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestStaticSphereSphere(const Sphere& a, const Sphere& b)
 {
-	real dist = (b.c - a.c).GetSquaredLength();
+	real dist = (b.c - a.c).squared_length();
 	return (dist < (b.r + a.r) * (b.r + a.r));
 }
 
@@ -274,8 +274,8 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 	real t0;	// Time at which the sphere intersects the plane remaining at the front side of the plane
 	real t1;	// Time at which the sphere intersects the plane remaining at the back side of the plane
 
-	real sphereToPlaneDistance = p.GetDistanceToPoint(sphereCenter);
-	real planeNormalDotVelocity = p.n.Dot(d);
+	real sphereToPlaneDistance = p.get_distance_to_point(sphereCenter);
+	real planeNormalDotVelocity = p.n.dot(d);
 
 	if (planeNormalDotVelocity > 0.0)
 	{
@@ -286,7 +286,7 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 	if (planeNormalDotVelocity == 0.0)
 	{
 		// If the sphere is embedded in the plane
-		if (Math::Abs(sphereToPlaneDistance) < sphereRadius)
+		if (math::abs(sphereToPlaneDistance) < sphereRadius)
 		{
 			t0 = 0.0;
 			t1 = 1.0;
@@ -305,7 +305,7 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 	// If _both_ t0 and t1 are outside [0,1] then collision can never happen
 	if (t0 >= 0.0 && t0 <= 1.0)
 	{
-		it = Math::Min(t0, t1);
+		it = math::min(t0, t1);
 		intersectionPoint = s.c - p.n * s.r + (d * it);
 		return true;
 	}
@@ -316,7 +316,7 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3& d, const Triangle& tri, real& it, Vec3& intersectionPoint)
 {
-	Plane triPlane = tri.ToPlane();
+	Plane triPlane = tri.to_plane();
 
 	// Test against the plane containing the triangle
 	real spherePlaneIt;
@@ -326,7 +326,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	}
 
 	// Check if the intersection point lies inside the triangle
-	if (tri.ContainsPoint(intersectionPoint))
+	if (tri.contains_point(intersectionPoint))
 	{
 		it = spherePlaneIt;
 		// intersectionPoint is already returned by the above call to TestDynamicSpherePlane
@@ -342,35 +342,35 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	real x1, x2;
 
 	// v1
-	a = d.Dot(d);
-	b = 2.0 * (d.Dot(s.c - tri.v1));
-	c = (tri.v1 - s.c).Dot(tri.v1 - s.c) - (s.r * s.r);
+	a = d.dot(d);
+	b = 2.0 * (d.dot(s.c - tri.v1));
+	c = (tri.v1 - s.c).dot(tri.v1 - s.c) - (s.r * s.r);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
-		it = Math::Min(x1, it);
+		it = math::min(x1, it);
 		intersectionPoint = tri.v1;
 		collisionFound = true;
 	}
 
 	// v2
-	b = 2.0 * (d.Dot(s.c - tri.v2));
-	c = (tri.v2 - s.c).Dot(tri.v2 - s.c) - (s.r * s.r);
+	b = 2.0 * (d.dot(s.c - tri.v2));
+	c = (tri.v2 - s.c).dot(tri.v2 - s.c) - (s.r * s.r);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
-		it = Math::Min(x1, it);
+		it = math::min(x1, it);
 		intersectionPoint = tri.v2;
 		collisionFound = true;
 	}
 
 	// v3
-	b = 2.0 * (d.Dot(s.c - tri.v3));
-	c = (tri.v3 - s.c).Dot(tri.v3 - s.c) - (s.r * s.r);
+	b = 2.0 * (d.dot(s.c - tri.v3));
+	c = (tri.v3 - s.c).dot(tri.v3 - s.c) - (s.r * s.r);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
-		it = Math::Min(x1, it);
+		it = math::min(x1, it);
 		intersectionPoint = tri.v3;
 		collisionFound = true;
 	}
@@ -383,28 +383,28 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	real edgeSquaredLength;
 	real velocitySquaredLength;
 
-	velocitySquaredLength = d.GetSquaredLength();
+	velocitySquaredLength = d.squared_length();
 
 	// e1
 	edge = tri.v2 - tri.v1;
 	centerToVertex = tri.v1 - s.c;
-	edgeDotVelocity = edge.Dot(d);
-	edgeDotCenterToVertex = edge.Dot(centerToVertex);
-	edgeSquaredLength = edge.GetSquaredLength();
+	edgeDotVelocity = edge.dot(d);
+	edgeDotCenterToVertex = edge.dot(centerToVertex);
+	edgeSquaredLength = edge.squared_length();
 
 
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
-	b = edgeSquaredLength * (2.0 * d.Dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
+	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.GetSquaredLength()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 		real f0 = (edgeDotVelocity * x1 - edgeDotCenterToVertex) / edgeSquaredLength;
 
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
-			it = Math::Min(x1, it);
+			it = math::min(x1, it);
 			intersectionPoint = tri.v1 + f0 * edge;
 			collisionFound = true;
 		}
@@ -413,23 +413,23 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	// e2
 	edge = tri.v3 - tri.v2;
 	centerToVertex = tri.v2 - s.c;
-	edgeDotVelocity = edge.Dot(d);
-	edgeDotCenterToVertex = edge.Dot(centerToVertex);
-	edgeSquaredLength = edge.GetSquaredLength();
+	edgeDotVelocity = edge.dot(d);
+	edgeDotCenterToVertex = edge.dot(centerToVertex);
+	edgeSquaredLength = edge.squared_length();
 
 
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
-	b = edgeSquaredLength * (2.0 * d.Dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
+	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.GetSquaredLength()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 		real f0 = (edgeDotVelocity * x1 - edgeDotCenterToVertex) / edgeSquaredLength;
 
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
-			it = Math::Min(x1, it);
+			it = math::min(x1, it);
 			intersectionPoint = tri.v2 + f0 * edge;
 			collisionFound = true;
 		}
@@ -438,23 +438,23 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	// e3
 	edge = tri.v1 - tri.v3;
 	centerToVertex = tri.v3 - s.c;
-	edgeDotVelocity = edge.Dot(d);
-	edgeDotCenterToVertex = edge.Dot(centerToVertex);
-	edgeSquaredLength = edge.GetSquaredLength();
+	edgeDotVelocity = edge.dot(d);
+	edgeDotCenterToVertex = edge.dot(centerToVertex);
+	edgeSquaredLength = edge.squared_length();
 
 
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
-	b = edgeSquaredLength * (2.0 * d.Dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
+	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.GetSquaredLength()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
-	if (Math::SolveQuadraticEquation(a, b, c, x1, x2))
+	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 		real f0 = (edgeDotVelocity * x1 - edgeDotCenterToVertex) / edgeSquaredLength;
 
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
-			it = Math::Min(x1, it);
+			it = math::min(x1, it);
 			intersectionPoint = tri.v3 + f0 * edge;
 			collisionFound = true;
 		}
@@ -469,7 +469,7 @@ inline bool Intersection::TestDynamicSphereSphere(const Sphere& s1, const Vec3&
 	// s1 == static sphere
 	// s2 == moving sphere
 	Vec3 d = d2 - d1;
-	d.Normalize();
+	d.normalize();
 
 	const Vec3& cs = s1.c;
 	const Vec3& cm = s2.c;
@@ -478,15 +478,15 @@ inline bool Intersection::TestDynamicSphereSphere(const Sphere& s1, const Vec3&
 	real r = s1.r + s2.r;
 
 	// If ||e|| < r, intersection occurs at t = 0
-	if (e.GetLength() < r)
+	if (e.length() < r)
 	{
 		it = 0.0;
 		return true;
 	}
 
 	// it == Intersection Time
-	real ed = e.Dot(d);
-	real squared = (ed * ed) + (r * r) - e.Dot(e);
+	real ed = e.dot(d);
+	real squared = (ed * ed) + (r * r) - e.dot(e);
 
 	// If the value inside the square root is neg, then no intersection
 	if (squared < 0.0)
@@ -494,8 +494,8 @@ inline bool Intersection::TestDynamicSphereSphere(const Sphere& s1, const Vec3&
 		return false;
 	}
 
-	real t = ed - Math::Sqrt(squared);
-	real l = (d2 - d1).GetLength();
+	real t = ed - math::sqrt(squared);
+	real l = (d2 - d1).length();
 
 	// If t < 0 || t > l, then non intersection in the considered period of time
 	if (t < 0.0 || t > l)
@@ -541,7 +541,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 	Vec3 tLeaveXYZ(1.0, 1.0, 1.0);
 
 	// If the resulting displacement equals zero, then fallback to static intersection test
-	if (Math::Equals(d.x, (real)0.0))
+	if (math::equals(d.x, (real)0.0))
 	{
 		if (b1.min.x > b2.max.x || b1.max.x < b2.min.x)
 		{
@@ -549,7 +549,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 		}
 	}
 
-	if (Math::Equals(d.y, (real)0.0))
+	if (math::equals(d.y, (real)0.0))
 	{
 		if (b1.min.y > b2.max.y || b1.max.y < b2.min.y)
 		{
@@ -557,7 +557,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 		}
 	}
 
-	if (Math::Equals(d.z, (real)0.0))
+	if (math::equals(d.z, (real)0.0))
 	{
 		if (b1.min.z > b2.max.z || b1.max.z < b2.min.z)
 		{
@@ -581,21 +581,21 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 	// We must ensure that enter time < leave time
 	if (tLeaveXYZ.x < tEnterXYZ.x)
 	{
-		Math::Swap(tLeaveXYZ.x, tEnterXYZ.x);
+		math::swap(tLeaveXYZ.x, tEnterXYZ.x);
 	}
 
 	if (tLeaveXYZ.y < tEnterXYZ.y)
 	{
-		Math::Swap(tLeaveXYZ.y, tEnterXYZ.y);
+		math::swap(tLeaveXYZ.y, tEnterXYZ.y);
 	}
 
 	if (tLeaveXYZ.z < tEnterXYZ.z)
 	{
-		Math::Swap(tLeaveXYZ.z, tEnterXYZ.z);
+		math::swap(tLeaveXYZ.z, tEnterXYZ.z);
 	}
 
-	real tEnter = Math::Max(tEnterXYZ.x, Math::Max(tEnterXYZ.y, tEnterXYZ.z));
-	real tLeave = Math::Min(tLeaveXYZ.x, Math::Min(tLeaveXYZ.y, tLeaveXYZ.z));
+	real tEnter = math::max(tEnterXYZ.x, math::max(tEnterXYZ.y, tEnterXYZ.z));
+	real tLeave = math::min(tLeaveXYZ.x, math::min(tLeaveXYZ.y, tLeaveXYZ.z));
 
 	// If tEnter > 1, then there is no intersection in the period
 	// of time cosidered
@@ -612,17 +612,17 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestFrustumSphere(const Frustum& f, const Sphere& s)
 {
-	if (f.mPlane[0].GetDistanceToPoint(s.c) < -s.r || f.mPlane[1].GetDistanceToPoint(s.c) < -s.r)
+	if (f.mPlane[0].get_distance_to_point(s.c) < -s.r || f.mPlane[1].get_distance_to_point(s.c) < -s.r)
 	{
 		return false;
 	}
 
-	if (f.mPlane[2].GetDistanceToPoint(s.c) < -s.r || f.mPlane[3].GetDistanceToPoint(s.c) < -s.r)
+	if (f.mPlane[2].get_distance_to_point(s.c) < -s.r || f.mPlane[3].get_distance_to_point(s.c) < -s.r)
 	{
 		return false;
 	}
 
-	if (f.mPlane[4].GetDistanceToPoint(s.c) < -s.r || f.mPlane[5].GetDistanceToPoint(s.c) < -s.r)
+	if (f.mPlane[4].get_distance_to_point(s.c) < -s.r || f.mPlane[5].get_distance_to_point(s.c) < -s.r)
 	{
 		return false;
 	}
@@ -641,7 +641,7 @@ inline bool Intersection::TestFrustumBox(const Frustum& f, const Box& b)
 
 		for (uint j = 0; j < 8; j++)
 		{
-			if (f.mPlane[i].GetDistanceToPoint(b.GetVertex(j)) < 0.0)
+			if (f.mPlane[i].get_distance_to_point(b.get_vertex(j)) < 0.0)
 			{
 				vertexOutCount++;
 			}
@@ -662,7 +662,7 @@ inline bool Intersection::TestFrustumBox(const Frustum& f, const Box& b)
 inline bool Intersection::TestCircleCircle(const Circle& c1, const Circle& c2, Vec2& penetration)
 {
 	Vec2 distance = c1.c - c2.c;
-	real distanceLen2 = distance.GetSquaredLength();
+	real distanceLen2 = distance.squared_length();
 	real radiusSum = c1.r + c2.r;
 	if (distanceLen2 > radiusSum*radiusSum)
 	{
@@ -675,7 +675,7 @@ inline bool Intersection::TestCircleCircle(const Circle& c1, const Circle& c2, V
 	}
 	else
 	{
-	  distanceLen2 = Math::Sqrt(distanceLen2);
+	  distanceLen2 = math::sqrt(distanceLen2);
 		penetration = distance * ((radiusSum - distanceLen2) / distanceLen2);
 	}
 	return true;
@@ -687,7 +687,7 @@ inline bool Intersection::TestDynamicCircleCircle(const Circle& c1, const Vec2&
 	// c1 == static circle
 	// c2 == moving circle
 	Vec2 d = d2 - d1;
-	d.Normalize();
+	d.normalize();
 
 	const Vec2& cs = c1.c;
 	const Vec2& cm = c2.c;
@@ -696,15 +696,15 @@ inline bool Intersection::TestDynamicCircleCircle(const Circle& c1, const Vec2&
 	real r = c1.r + c2.r;
 
 	// If ||e|| < r, intersection occurs at t = 0
-	if (e.GetLength() < r)
+	if (e.length() < r)
 	{
 		it = 0.0;
 		return true;
 	}
 
 	// it == Intersection Time
-	real ed = e.Dot(d);
-	real squared = (ed * ed) + (r * r) - e.Dot(e);
+	real ed = e.dot(d);
+	real squared = (ed * ed) + (r * r) - e.dot(e);
 
 	// If the value inside the square root is neg, then no intersection
 	if (squared < 0.0)
@@ -712,8 +712,8 @@ inline bool Intersection::TestDynamicCircleCircle(const Circle& c1, const Vec2&
 		return false;
 	}
 
-	real t = ed - Math::Sqrt(squared);
-	real l = (d2 - d1).GetLength();
+	real t = ed - math::sqrt(squared);
+	real l = (d2 - d1).length();
 
 	// If t < 0 || t > l, then non intersection in the considered period of time
 	if (t < 0.0 || t > l)
@@ -770,7 +770,7 @@ inline bool Intersection::TestRectRect(const Rect& r1, const Rect& r2, Vec2& pen
 		penetration.y = min2MinusMax1;
 	}
 
-	if (Math::Abs(penetration.x) < Math::Abs(penetration.y))
+	if (math::abs(penetration.x) < math::abs(penetration.y))
 	{
 		penetration.y = 0.0;
 	}
@@ -835,7 +835,7 @@ inline bool Intersection::TestCircleRect(const Circle& c1, const Rect& r2, Vec2&
 	else
 	{
 		penetration += Vec2(c1.r, c1.r);
-		real len = Math::Sqrt(penetration.GetSquaredLength());
+		real len = math::sqrt(penetration.squared_length());
 		if (len > c1.r)
 		{
 			return false;

+ 41 - 41
src/core/math/Mat3.cpp

@@ -332,41 +332,41 @@ Mat3 operator*(real k, const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::BuildRotationX(real radians)
+void Mat3::build_rotation_x(real radians)
 {
 	m[0] = 1.0;
 	m[1] = 0.0;
 	m[2] = 0.0;
 	m[3] = 0.0;
-	m[4] = Math::Cos(radians);
-	m[5] = Math::Sin(radians);
+	m[4] = math::cos(radians);
+	m[5] = math::sin(radians);
 	m[6] = 0.0;
-	m[7] = -Math::Sin(radians);
-	m[8] = Math::Cos(radians);
+	m[7] = -math::sin(radians);
+	m[8] = math::cos(radians);
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::BuildRotationY(real radians)
+void Mat3::build_rotation_y(real radians)
 {
-	m[0] = Math::Cos(radians);
+	m[0] = math::cos(radians);
 	m[1] = 0.0;
-	m[2] = -Math::Sin(radians);
+	m[2] = -math::sin(radians);
 	m[3] = 0.0;
 	m[4] = 1.0;
 	m[5] = 0.0;
-	m[6] = Math::Sin(radians);
+	m[6] = math::sin(radians);
 	m[7] = 0.0;
-	m[8] = Math::Cos(radians);
+	m[8] = math::cos(radians);
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::BuildRotationZ(real radians)
+void Mat3::build_rotation_z(real radians)
 {
-	m[0] = Math::Cos(radians);
-	m[1] = Math::Sin(radians);
+	m[0] = math::cos(radians);
+	m[1] = math::sin(radians);
 	m[2] = 0.0;
-	m[3] = -Math::Sin(radians);
-	m[4] = Math::Cos(radians);
+	m[3] = -math::sin(radians);
+	m[4] = math::cos(radians);
 	m[5] = 0.0;
 	m[6] = 0.0;
 	m[7] = 0.0;
@@ -374,11 +374,11 @@ void Mat3::BuildRotationZ(real radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::BuildRotation(const Vec3& n, real radians)
+void Mat3::build_rotation(const Vec3& n, real radians)
 {
-	real a = (real)1.0 - Math::Cos(radians);
-	real sin_a = Math::Sin(radians);
-	real cos_a = Math::Cos(radians);
+	real a = (real)1.0 - math::cos(radians);
+	real sin_a = math::sin(radians);
+	real cos_a = math::cos(radians);
 
 	m[0] = n.x * n.x * a + cos_a;
 	m[1] = n.x * n.y * a + n.z * sin_a;
@@ -392,7 +392,7 @@ void Mat3::BuildRotation(const Vec3& n, real radians)
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::Transpose()
+Mat3& Mat3::transpose()
 {
 	real tmp;
 
@@ -412,7 +412,7 @@ Mat3& Mat3::Transpose()
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::GetTransposed() const
+Mat3 Mat3::get_transposed() const
 {
 	Mat3 tmp;
 
@@ -430,7 +430,7 @@ Mat3 Mat3::GetTransposed() const
 }
 
 //-----------------------------------------------------------------------------
-real Mat3::GetDeterminant() const
+real Mat3::get_determinant() const
 {
 	real det;
 
@@ -442,7 +442,7 @@ real Mat3::GetDeterminant() const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::Invert()
+Mat3& Mat3::invert()
 {
 	Mat3 mat;
 	real det;
@@ -475,22 +475,22 @@ Mat3& Mat3::Invert()
 }
 
 //-----------------------------------------------------------------------------
-inline Mat3 Mat3::GetInverted() const
+inline Mat3 Mat3::get_inverted() const
 {
 	Mat3 tmp(*this);
 
-	return tmp.Invert();
+	return tmp.invert();
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::LoadIdentity()
+void Mat3::load_identity()
 {
 	m[0] = m[4] = m[8] = 1.0;
 	m[1] = m[2] = m[3] = m[5] = m[6] = m[7] = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::GetScale() const
+Vec3 Mat3::get_scale() const
 {
 	Vec3 tmp;
 
@@ -502,7 +502,7 @@ Vec3 Mat3::GetScale() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::SetScale(const Vec3& scale)
+void Mat3::set_scale(const Vec3& scale)
 {
 	m[0] = scale.x;
 	m[4] = scale.y;
@@ -510,52 +510,52 @@ void Mat3::SetScale(const Vec3& scale)
 }
 
 //-----------------------------------------------------------------------------
-real* Mat3::ToFloatPtr()
+real* Mat3::to_float_ptr()
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-const real* Mat3::ToFloatPtr() const
+const real* Mat3::to_float_ptr() const
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-Angles Mat3::ToAngles() const
+Angles Mat3::to_angles() const
 {
 	Angles tmp;
 	real sp = -m[7];
 
 	if (sp <= -1.0)
 	{
-		tmp.pitch = -Math::HALF_PI;
+		tmp.pitch = -math::HALF_PI;
 	}
 	else if (sp >= 1.0)
 	{
-		tmp.pitch = Math::HALF_PI;
+		tmp.pitch = math::HALF_PI;
 	}
 	else
 	{
-		tmp.pitch = Math::Asin(-m[8]);
+		tmp.pitch = math::asin(-m[8]);
 	}
 
 	if (sp > 0.9999)
 	{
 		tmp.bank = 0.0;
-		tmp.heading = Math::Atan2(-m[2], m[0]);
+		tmp.heading = math::atan2(-m[2], m[0]);
 	}
 	else
 	{
-		tmp.heading = Math::Atan2(m[6], m[8]);
-		tmp.bank = Math::Atan2(m[1], m[4]);
+		tmp.heading = math::atan2(m[6], m[8]);
+		tmp.bank = math::atan2(m[1], m[4]);
 	}
 
 	return tmp;
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat3::ToMat4() const
+Mat4 Mat3::to_mat4() const
 {
 	Mat4 tmp;
 
@@ -580,7 +580,7 @@ Mat4 Mat3::ToMat4() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Mat3::ToQuat() const
+Quat Mat3::to_quat() const
 {
 	Quat tmp;
 
@@ -609,7 +609,7 @@ Quat Mat3::ToQuat() const
 		index = 3;
 	}
 
-	real biggest = Math::Sqrt(fourMaxSquaredMinusOne + (real)1.0) * (real)0.5;
+	real biggest = math::sqrt(fourMaxSquaredMinusOne + (real)1.0) * (real)0.5;
 	real mult = (real)0.25 / biggest;
 
 	switch (index)
@@ -644,7 +644,7 @@ Quat Mat3::ToQuat() const
 }
 
 //-----------------------------------------------------------------------------
-Str Mat3::ToStr() const
+Str Mat3::to_str() const
 {
 	Str tmp;
 

+ 22 - 22
src/core/math/Mat3.h

@@ -93,28 +93,28 @@ public:
 
 	friend Mat3			operator*(real k, const Mat3& a);			//!< For simmetry
 
-	void				BuildRotationX(real radians);				//!< Builds a rotation matrix about the X axis of "radians" radians
-	void				BuildRotationY(real radians);				//!< Builds a rotation matrix about the Y axis of "radians" radians
-	void				BuildRotationZ(real radians);				//!< Builds a rotation matrix about the Z axis of "radians" radians
-	void				BuildRotation(const Vec3& n, real radians);	//!< Builds a rotation matrix about an arbitrary axis of "radians" radians
-
-	Mat3&				Transpose();								//!< Transposes the matrix
-	Mat3				GetTransposed() const;						//!< Returns the transposed of the matrix
-	real				GetDeterminant() const;						//!< Returns the matrix's determinant
-	Mat3&				Invert();									//!< Builds the inverse of the matrix
-	Mat3				GetInverted() const;						//!< Returns the inverse of the matrix
-
-	void				LoadIdentity();								//!< Builds the identity matrix
-
-	Vec3				GetScale() const;							//!< Returns a Vec3 containing the matrix's scale portion
-	void				SetScale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
-
-	real*				ToFloatPtr();								//!< Returns the pointer to the matrix's data
-	const real*			ToFloatPtr() const;							//!< Returns the pointer to the matrix's data
-	Str					ToStr() const;								//!< Returns a Str containing the matrix's components
-	Angles				ToAngles() const;							//!< Returns an angles according to the matrix's rotation portion
-	Mat4				ToMat4() const;								//!< Returns a 4x4 matrix according to the matrix's rotation portion
-	Quat				ToQuat() const;								//!< Returns a quaternion according to the matrix's rotation portion
+	void				build_rotation_x(real radians);				//!< Builds a rotation matrix about the X axis of "radians" radians
+	void				build_rotation_y(real radians);				//!< Builds a rotation matrix about the Y axis of "radians" radians
+	void				build_rotation_z(real radians);				//!< Builds a rotation matrix about the Z axis of "radians" radians
+	void				build_rotation(const Vec3& n, real radians);//!< Builds a rotation matrix about an arbitrary axis of "radians" radians
+
+	Mat3&				transpose();								//!< Transposes the matrix
+	Mat3				get_transposed() const;						//!< Returns the transposed of the matrix
+	real				get_determinant() const;					//!< Returns the matrix's determinant
+	Mat3&				invert();									//!< Builds the inverse of the matrix
+	Mat3				get_inverted() const;						//!< Returns the inverse of the matrix
+
+	void				load_identity();							//!< Builds the identity matrix
+
+	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
+	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
+
+	real*				to_float_ptr();								//!< Returns the pointer to the matrix's data
+	const real*			to_float_ptr() const;						//!< Returns the pointer to the matrix's data
+	Str					to_str() const;								//!< Returns a Str containing the matrix's components
+	Angles				to_angles() const;							//!< Returns an angles according to the matrix's rotation portion
+	Mat4				to_mat4() const;							//!< Returns a 4x4 matrix according to the matrix's rotation portion
+	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 
 	static const Mat3	IDENTITY;
 };

+ 71 - 71
src/core/math/Mat4.cpp

@@ -445,19 +445,19 @@ Mat4 operator*(real k, const Mat4& a)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildRotationX(real radians)
+void Mat4::build_rotation_x(real radians)
 {
 	m[0] = 1.0;
 	m[1] = 0.0;
 	m[2] = 0.0;
 	m[3] = 0.0;
 	m[4] = 0.0;
-	m[5] = Math::Cos(radians);
-	m[6] = Math::Sin(radians);
+	m[5] = math::cos(radians);
+	m[6] = math::sin(radians);
 	m[7] = 0.0;
 	m[8] = 0.0;
-	m[9] = -Math::Sin(radians);
-	m[10] = Math::Cos(radians);
+	m[9] = -math::sin(radians);
+	m[10] = math::cos(radians);
 	m[11] = 0.0;
 	m[12] = 0.0;
 	m[13] = 0.0;
@@ -466,19 +466,19 @@ void Mat4::BuildRotationX(real radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildRotationY(real radians)
+void Mat4::build_rotation_y(real radians)
 {
-	m[0] = Math::Cos(radians);
+	m[0] = math::cos(radians);
 	m[1] = 0.0;
-	m[2] = -Math::Sin(radians);
+	m[2] = -math::sin(radians);
 	m[3] = 0.0;
 	m[4] = 0.0;
 	m[5] = 1.0;
 	m[6] = 0.0;
 	m[7] = 0.0;
-	m[8] = Math::Sin(radians);
+	m[8] = math::sin(radians);
 	m[9] = 0.0;
-	m[10] = Math::Cos(radians);
+	m[10] = math::cos(radians);
 	m[11] = 0.0;
 	m[12] = 0.0;
 	m[13] = 0.0;
@@ -487,14 +487,14 @@ void Mat4::BuildRotationY(real radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildRotationZ(real radians)
+void Mat4::build_rotation_z(real radians)
 {
-	m[0] = Math::Cos(radians);
-	m[1] = Math::Sin(radians);
+	m[0] = math::cos(radians);
+	m[1] = math::sin(radians);
 	m[2] = 0.0;
 	m[3] = 0.0;
-	m[4] = -Math::Sin(radians);
-	m[5] = Math::Cos(radians);
+	m[4] = -math::sin(radians);
+	m[5] = math::cos(radians);
 	m[6] = 0.0;
 	m[7] = 0.0;
 	m[8] = 0.0;
@@ -508,11 +508,11 @@ void Mat4::BuildRotationZ(real radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildRotation(const Vec3& n, real radians)
+void Mat4::build_rotation(const Vec3& n, real radians)
 {
-	real a = (real)1.0 - Math::Cos(radians);
-	real sin_a = Math::Sin(radians);
-	real cos_a = Math::Cos(radians);
+	real a = (real)1.0 - math::cos(radians);
+	real sin_a = math::sin(radians);
+	real cos_a = math::cos(radians);
 
 	m[0] = n.x * n.x * a + cos_a;
 	m[1] = n.x * n.y * a + n.z * sin_a;
@@ -533,11 +533,11 @@ void Mat4::BuildRotation(const Vec3& n, real radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildProjectionPerspectiveRH(real fovy, real aspect, real near, real far)
+void Mat4::build_projection_perspective_rh(real fovy, real aspect, real near, real far)
 {
 	double top, right;
 
-	top = Math::Tan((real)((double)fovy / 360.0 * Math::PI)) * (double)near;
+	top = math::tan((real)((double)fovy / 360.0 * math::PI)) * (double)near;
 	right = top * aspect;
 
 	m[0] = (real)(near / right);
@@ -559,11 +559,11 @@ void Mat4::BuildProjectionPerspectiveRH(real fovy, real aspect, real near, real
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildProjectionPerspectiveLH(real fovy, real aspect, real near, real far)
+void Mat4::build_projection_perspective_lh(real fovy, real aspect, real near, real far)
 {
 	double top, right;
 
-	top = Math::Tan((real)((double)fovy / 360.0 * Math::PI)) * (double)near;
+	top = math::tan((real)((double)fovy / 360.0 * math::PI)) * (double)near;
 	right = top * aspect;
 
 	m[0] = (real)(near / right);
@@ -585,7 +585,7 @@ void Mat4::BuildProjectionPerspectiveLH(real fovy, real aspect, real near, real
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildProjectionOrthoRH(real width, real height, real near, real far)
+void Mat4::build_projection_ortho_rh(real width, real height, real near, real far)
 {
 	m[0] = (real)2.0 / width;
 	m[1] = 0.0;
@@ -606,7 +606,7 @@ void Mat4::BuildProjectionOrthoRH(real width, real height, real near, real far)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildProjectionOrthoLH(real width, real height, real near, real far)
+void Mat4::build_projection_ortho_lh(real width, real height, real near, real far)
 {
 	m[0] = (real)2.0 / width;
 	m[1] = 0.0;
@@ -627,7 +627,7 @@ void Mat4::BuildProjectionOrthoLH(real width, real height, real near, real far)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildProjectionOrtho2dRH(real width, real height, real near, real far)
+void Mat4::build_projection_ortho_2d_rh(real width, real height, real near, real far)
 {
 	m[0] = (real)2.0 / width;
 	m[1] = 0.0;
@@ -648,7 +648,7 @@ void Mat4::BuildProjectionOrtho2dRH(real width, real height, real near, real far
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::Transpose()
+Mat4& Mat4::transpose()
 {
 	real tmp;
 
@@ -680,7 +680,7 @@ Mat4& Mat4::Transpose()
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::GetTransposed() const
+Mat4 Mat4::get_transposed() const
 {
 	Mat4 tmp;
 
@@ -705,13 +705,13 @@ Mat4 Mat4::GetTransposed() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildLookAtRH(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Mat4::build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up)
 {
 	Vec3 zAxis =  pos - target;
-	zAxis.Normalize();
+	zAxis.normalize();
 
-	Vec3 xAxis = up.Cross(zAxis);
-	Vec3 yAxis = zAxis.Cross(xAxis);
+	Vec3 xAxis = up.cross(zAxis);
+	Vec3 yAxis = zAxis.cross(xAxis);
 
 	m[0] = xAxis.x;
 	m[1] = yAxis.x;
@@ -725,20 +725,20 @@ void Mat4::BuildLookAtRH(const Vec3& pos, const Vec3& target, const Vec3& up)
 	m[9] = yAxis.z;
 	m[10] = zAxis.z;
 	m[11] = 0.0;
-	m[12] = -pos.Dot(xAxis);
-	m[13] = -pos.Dot(yAxis);
-	m[14] = -pos.Dot(zAxis);
+	m[12] = -pos.dot(xAxis);
+	m[13] = -pos.dot(yAxis);
+	m[14] = -pos.dot(zAxis);
 	m[15] = 1.0;
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildLookAtLH(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Mat4::build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up)
 {
 	Vec3 zAxis =  target - pos;
-	zAxis.Normalize();
+	zAxis.normalize();
 
-	Vec3 xAxis = up.Cross(zAxis);
-	Vec3 yAxis = zAxis.Cross(xAxis);
+	Vec3 xAxis = up.cross(zAxis);
+	Vec3 yAxis = zAxis.cross(xAxis);
 
 	m[0] = xAxis.x;
 	m[1] = yAxis.x;
@@ -752,20 +752,20 @@ void Mat4::BuildLookAtLH(const Vec3& pos, const Vec3& target, const Vec3& up)
 	m[9] = yAxis.z;
 	m[10] = zAxis.z;
 	m[11] = 0.0;
-	m[12] = -pos.Dot(xAxis);
-	m[13] = -pos.Dot(yAxis);
-	m[14] = -pos.Dot(zAxis);
+	m[12] = -pos.dot(xAxis);
+	m[13] = -pos.dot(yAxis);
+	m[14] = -pos.dot(zAxis);
 	m[15] = 1.0;
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildViewpointBillboard(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Mat4::build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up)
 {
 	Vec3 zAxis = target - pos;
-	zAxis.Normalize();
+	zAxis.normalize();
 
-	Vec3 xAxis = up.Cross(zAxis).Normalize();
-	Vec3 yAxis = zAxis.Cross(xAxis).Normalize();
+	Vec3 xAxis = up.cross(zAxis).normalize();
+	Vec3 yAxis = zAxis.cross(xAxis).normalize();
 
 	m[0] = xAxis.x;
 	m[1] = xAxis.y;
@@ -786,12 +786,12 @@ void Mat4::BuildViewpointBillboard(const Vec3& pos, const Vec3& target, const Ve
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::BuildAxisBillboard(const Vec3& pos, const Vec3& target, const Vec3& axis)
+void Mat4::build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis)
 {
 	Vec3 zAxis = target - pos;
 
-	Vec3 xAxis = axis.Cross(zAxis).Normalize();
-	zAxis = axis.Cross(xAxis).Normalize();
+	Vec3 xAxis = axis.cross(zAxis).normalize();
+	zAxis = axis.cross(xAxis).normalize();
 	const Vec3& yAxis = axis;
 
 	m[0] = xAxis.x;
@@ -813,7 +813,7 @@ void Mat4::BuildAxisBillboard(const Vec3& pos, const Vec3& target, const Vec3& a
 }
 
 //-----------------------------------------------------------------------------
-real Mat4::GetDeterminant() const
+real Mat4::get_determinant() const
 {
 	real det;
 
@@ -833,7 +833,7 @@ real Mat4::GetDeterminant() const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::Invert()
+Mat4& Mat4::invert()
 {
 	Mat4 mat;
 	real det;
@@ -899,22 +899,22 @@ Mat4& Mat4::Invert()
 }
 
 //-----------------------------------------------------------------------------
-inline Mat4 Mat4::GetInverted() const
+inline Mat4 Mat4::get_inverted() const
 {
 	Mat4 tmp(*this);
 
-	return tmp.Invert();
+	return tmp.invert();
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::LoadIdentity()
+void Mat4::load_identity()
 {
 	m[0] = m[5] = m[10] = m[15] = 1.0;
 	m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::GetTranslation() const
+Vec3 Mat4::get_translation() const
 {
 	Vec3 tmp;
 
@@ -926,7 +926,7 @@ Vec3 Mat4::GetTranslation() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::SetTranslation(const Vec3& trans)
+void Mat4::set_translation(const Vec3& trans)
 {
 	m[12] = trans.x;
 	m[13] = trans.y;
@@ -934,7 +934,7 @@ void Mat4::SetTranslation(const Vec3& trans)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::GetScale() const
+Vec3 Mat4::get_scale() const
 {
 	Vec3 tmp;
 
@@ -946,7 +946,7 @@ Vec3 Mat4::GetScale() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::SetScale(const Vec3& scale)
+void Mat4::set_scale(const Vec3& scale)
 {
 	m[0] = scale.x;
 	m[5] = scale.y;
@@ -954,52 +954,52 @@ void Mat4::SetScale(const Vec3& scale)
 }
 
 //-----------------------------------------------------------------------------
-real* Mat4::ToFloatPtr()
+real* Mat4::to_float_ptr()
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-const real* Mat4::ToFloatPtr() const
+const real* Mat4::to_float_ptr() const
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-Angles Mat4::ToAngles() const
+Angles Mat4::to_angles() const
 {
 	Angles tmp;
 	real sp = -m[9];
 
 	if (sp <= -1.0)
 	{
-		tmp.pitch = -Math::HALF_PI;
+		tmp.pitch = -math::HALF_PI;
 	}
 	else if (sp >= 1.0)
 	{
-		tmp.pitch = Math::HALF_PI;
+		tmp.pitch = math::HALF_PI;
 	}
 	else
 	{
-		tmp.pitch = Math::Asin(-m[9]);
+		tmp.pitch = math::asin(-m[9]);
 	}
 
 	if (sp > 0.9999)
 	{
 		tmp.bank = 0.0;
-		tmp.heading = Math::Atan2(-m[2], m[0]);
+		tmp.heading = math::atan2(-m[2], m[0]);
 	}
 	else
 	{
-		tmp.heading = Math::Atan2(m[8], m[10]);
-		tmp.bank = Math::Atan2(m[1], m[5]);
+		tmp.heading = math::atan2(m[8], m[10]);
+		tmp.bank = math::atan2(m[1], m[5]);
 	}
 
 	return tmp;
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat4::ToMat3() const
+Mat3 Mat4::to_mat3() const
 {
 	Mat3 tmp;
 
@@ -1017,7 +1017,7 @@ Mat3 Mat4::ToMat3() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Mat4::ToQuat() const
+Quat Mat4::to_quat() const
 {
 	Quat tmp;
 	real fourWSquaredMinusOne = m[0] + m[5] + m[10];
@@ -1045,7 +1045,7 @@ Quat Mat4::ToQuat() const
 		index = 3;
 	}
 
-	real biggest = Math::Sqrt(fourMaxSquaredMinusOne + (real)1.0) * (real)0.5;
+	real biggest = math::sqrt(fourMaxSquaredMinusOne + (real)1.0) * (real)0.5;
 	real mult = (real)0.25 / biggest;
 
 	switch (index)
@@ -1080,7 +1080,7 @@ Quat Mat4::ToQuat() const
 }
 
 //-----------------------------------------------------------------------------
-Str Mat4::ToStr() const
+Str Mat4::to_str() const
 {
 	Str tmp;
 

+ 35 - 35
src/core/math/Mat4.h

@@ -97,41 +97,41 @@ public:
 
 	friend Mat4			operator*(real k, const Mat4& a);			//!< For simmetry
 
-	void				BuildRotationX(real radians);				//!< Builds a rotation matrix about the X axis of "radians" radians
-	void				BuildRotationY(real radians);				//!< Builds a rotation matrix about the Y axis of "radians" radians
-	void				BuildRotationZ(real radians);				//!< Builds a rotation matrix about the Z axis of "radians" radians
-	void				BuildRotation(const Vec3& n, real radians);	//!< Builds a rotation matrix about an arbitrary axis of "radians" radians
-	void				BuildProjectionPerspectiveRH(real fovy, real aspect, real near, real far);	//!< Builds a perspetive projection matrix suited to Right-Handed coordinate systems
-	void				BuildProjectionPerspectiveLH(real fovy, real aspect, real near, real far);	//!< Builds a perspective projection matrix suited to Left-Handed coordinate systems
-	void				BuildProjectionOrthoRH(real width, real height, real near, real far);	//!< Builds an orthographic projection matrix suited to Right-Handed coordinate systems
-	void				BuildProjectionOrthoLH(real width, real height, real near, real far);	//!< Builds an orthographic projection matrix suited to Left-Handed coordinate systems
-	void				BuildProjectionOrtho2dRH(real width, real height, real near, real far);	//!< Builds a 2d orthographic projection matrix suited to Right-Handed coordinate systems
-
-	void				BuildLookAtRH(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Righ-Handed look-at" matrix from a position, a target, and an up vector
-	void				BuildLookAtLH(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Left-Handed look-at" matrix from a position, a target, and an up vector
-	void				BuildViewpointBillboard(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Viewpoint-Oriented billboard" matrix which can be used to make an object face a specific point in space
-	void				BuildAxisBillboard(const Vec3& pos, const Vec3& target, const Vec3& axis);	//!< Builds a "Arbitrary-Axis billboard" matrix which can be used to make an object face a specific point in space
-
-	Mat4&				Transpose();								//!< Transposes the matrix
-	Mat4				GetTransposed() const;						//!< Returns the transposed of the matrix
-	real				GetDeterminant() const;						//!< Returns the matrix's determinant
-	Mat4&				Invert();									//!< Inverts the matrix
-	Mat4				GetInverted() const;						//!< Returns the inverse of the matrix
-
-	void				LoadIdentity();								//!< Builds the identity matrix
-
-	Vec3				GetTranslation() const;						//!< Returns a Vec3 containing the matrix's translation portion
-	void				SetTranslation(const Vec3& trans);			//!< Fills the matrix's translation portion values contained in "trans"
-
-	Vec3				GetScale() const;							//!< Returns a Vec3 containing the matrix's scale portion
-	void				SetScale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
-
-	real*				ToFloatPtr();								//!< Returns the pointer to the matrix's data
-	const real*			ToFloatPtr() const;							//!< Returns the pointer to the matrix's data
-	Angles				ToAngles() const;							//!< Returns an angles according to the matrix's rotation portion
-	Mat3				ToMat3() const;								//!< Returns a 3x3 matrix according to the matrix's rotation portion
-	Quat				ToQuat() const;								//!< Returns a quaternion according to the matrix's rotation portion
-	Str					ToStr() const;								//!< Returns a Str containing the matrix's components
+	void				build_rotation_x(real radians);				//!< Builds a rotation matrix about the X axis of "radians" radians
+	void				build_rotation_y(real radians);				//!< Builds a rotation matrix about the Y axis of "radians" radians
+	void				build_rotation_z(real radians);				//!< Builds a rotation matrix about the Z axis of "radians" radians
+	void				build_rotation(const Vec3& n, real radians);//!< Builds a rotation matrix about an arbitrary axis of "radians" radians
+	void				build_projection_perspective_rh(real fovy, real aspect, real near, real far);	//!< Builds a perspetive projection matrix suited to Right-Handed coordinate systems
+	void				build_projection_perspective_lh(real fovy, real aspect, real near, real far);	//!< Builds a perspective projection matrix suited to Left-Handed coordinate systems
+	void				build_projection_ortho_rh(real width, real height, real near, real far);		//!< Builds an orthographic projection matrix suited to Right-Handed coordinate systems
+	void				build_projection_ortho_lh(real width, real height, real near, real far);		//!< Builds an orthographic projection matrix suited to Left-Handed coordinate systems
+	void				build_projection_ortho_2d_rh(real width, real height, real near, real far);	//!< Builds a 2d orthographic projection matrix suited to Right-Handed coordinate systems
+
+	void				build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Righ-Handed look-at" matrix from a position, a target, and an up vector
+	void				build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Left-Handed look-at" matrix from a position, a target, and an up vector
+	void				build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Viewpoint-Oriented billboard" matrix which can be used to make an object face a specific point in space
+	void				build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis);	//!< Builds a "Arbitrary-Axis billboard" matrix which can be used to make an object face a specific point in space
+
+	Mat4&				transpose();								//!< Transposes the matrix
+	Mat4				get_transposed() const;						//!< Returns the transposed of the matrix
+	real				get_determinant() const;					//!< Returns the matrix's determinant
+	Mat4&				invert();									//!< Inverts the matrix
+	Mat4				get_inverted() const;						//!< Returns the inverse of the matrix
+
+	void				load_identity();							//!< Builds the identity matrix
+
+	Vec3				get_translation() const;					//!< Returns a Vec3 containing the matrix's translation portion
+	void				set_translation(const Vec3& trans);			//!< Fills the matrix's translation portion values contained in "trans"
+
+	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
+	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
+
+	real*				to_float_ptr();								//!< Returns the pointer to the matrix's data
+	const real*			to_float_ptr() const;						//!< Returns the pointer to the matrix's data
+	Angles				to_angles() const;							//!< Returns an angles according to the matrix's rotation portion
+	Mat3				to_mat3() const;							//!< Returns a 3x3 matrix according to the matrix's rotation portion
+	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
+	Str					to_str() const;								//!< Returns a Str containing the matrix's components
 
 	static const Mat4	IDENTITY;
 };

+ 0 - 16
src/core/math/MathUtils.cpp

@@ -29,22 +29,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace Crown
 {
 
-const real		Math::PI						= (real)3.1415926535897932;
-const real		Math::TWO_PI					= PI * (real)2.0;
-const real		Math::HALF_PI					= PI * (real)0.5;
-const real		Math::ONEFOURTH_PI				= PI * (real)0.25;
-
-const real		Math::DEG_TO_RAD				= PI / (real)180.0;
-const real		Math::RAD_TO_DEG				= (real)1.0 / DEG_TO_RAD;
-
-const real		Math::FOUR_OVER_THREE			= (real)(4.0 / 3.0);
-const real		Math::FOUR_OVER_THREE_TIMES_PI	= FOUR_OVER_THREE * PI;
-
-const real		Math::ONE_OVER_THREE			= (real)(1.0 / 3.0);
-const real		Math::ONE_OVER_255				= (real)(1.0 / 255.0);
-
-const float		Math::FLOAT_PRECISION			= (real)1.0e-7f;
-const double	Math::DOUBLE_PRECISION			= (real)1.0e-9;
 
 } // namespace Crown
 

+ 88 - 111
src/core/math/MathUtils.h

@@ -38,140 +38,116 @@ namespace Crown
 /**
 	Math utilities.
 */
-class Math
+namespace math
 {
 
-public:
-
-							/**
-								Returns whether "a" and "b" are equal according to the specified precision.
-							@warning:
-								Use this only for comparing very little values. 0.0 to 10.0 should
-								be fine.
-							*/
-	static bool				Equals(float a, float b, float precision = Math::FLOAT_PRECISION);
-							/**
-								Returns whether "a" and "b" are equal according to the specified precision.
-							@warning:
-								Use this only for comparing very little values. 0.0 to 10.0 should
-								be fine.
-							*/
-	static bool				Equals(double a, double b, double precision = Math::DOUBLE_PRECISION);
-
-	static bool				TestBitmask(int value, int bitmask);	//!< Tests agains a specified bitmask and returns true only if all bits are satisfied
-	static int				SetBitmask(int value, int bitmask);		//!< Sets the specified bitmask
-	static int				UnsetBitmask(int value, int bitmask);	//!< Removes the specified bitmask
-
-	template <typename T>
-	static T				Min(const T& a, const T& b);		//!< Returns minimum between two values
-	template <typename T>
-	static T				Max(const T& a, const T& b);		//!< Returns maximum between two values
-	template <typename T>
-	static T				Avg(const T& a, const T& b);		//!< Returns the arithmetic mean of a and b
-	template <typename T>
-	static T				ClampToRange(const T& min, const T& max, const T& value);	//!< Clamps a value to a specific range (min < max)
-	template <typename T>
-	static void				Swap(T& a, T& b);					//!< Swaps two values
-
-	static real				DegToRad(real deg);					//!< Returns "deg" in radians
-	static real				RadToDeg(real rad);					//!< Returns "rad" in degrees
-	static uint				NextPow2(uint x);					//!< Returns the nearest power of two to "x"
-	static bool				IsPow2(uint x);						//!< Returns whether "x" is power of two
-	static real				Ceil(real x);						//!< Returns the smallest integral value that is not less than x
-	static real				Floor(real x);						//!< Returns the largest integral value that is not greater than x
-	static real				Sqrt(real x);						//!< Returns the square root of "x"
-	static real				InvSqrt(real x);					//!< Returns the inverse square root of "x"
-	static real				Sin(real x);						//!< Returns the sine of "x"
-	static real				Cos(real x);						//!< Returns the cosine of "x"
-	static real				Asin(real x);						//!< Returns the arc sine of "x"
-	static real				Acos(real x);						//!< Returns the arc cosine of "x"
-	static real				Tan(real x);						//!< Returns the tangent of "x"
-	static real				Atan2(real y, real x);				//!< Returns the arc tangent of "y" / "x"
-	static real				Abs(real x);						//!< Returns the absolute value of "x"
-	static real				FMod(real n, real d);				//!< Returns the realing-point remainder of numerator/denominator
-
-
-							//! Returns true if there are solutions and puts them in 'x1' and 'x2' (x1 <= x2)
-	static bool				SolveQuadraticEquation(real a, real b, real c, real& x1, real& x2);
-
-	// Useful constants
-	static const real		PI;
-	static const real		TWO_PI;
-	static const real		HALF_PI;
-	static const real		ONEFOURTH_PI;
-
-	static const real		DEG_TO_RAD;
-	static const real		RAD_TO_DEG;
-
-	static const real		FOUR_OVER_THREE;
-	static const real		FOUR_OVER_THREE_TIMES_PI;
-
-	static const real		ONE_OVER_THREE;
-	static const real		ONE_OVER_255;
-
-	static const float		FLOAT_PRECISION;
-	static const double		DOUBLE_PRECISION;
-
-private:
-
-	// Disable construction
-	Math();
-};
+// Constants
+const real		PI							= (real)3.1415926535897932;
+const real		TWO_PI						= PI * (real)2.0;
+const real		HALF_PI						= PI * (real)0.5;
+const real		ONEFOURTH_PI				= PI * (real)0.25;
+
+const real		DEG_TO_RAD					= PI / (real)180.0;
+const real		RAD_TO_DEG					= (real)1.0 / DEG_TO_RAD;
+
+const real		FOUR_OVER_THREE				= (real)(4.0 / 3.0);
+const real		FOUR_OVER_THREE_TIMES_PI	= FOUR_OVER_THREE * PI;
+
+const real		ONE_OVER_THREE				= (real)(1.0 / 3.0);
+const real		ONE_OVER_255				= (real)(1.0 / 255.0);
+
+const float		FLOAT_PRECISION				= (real)1.0e-7f;
+const double	DOUBLE_PRECISION			= (real)1.0e-9;
+
+bool			equals(float a, float b, float precision = FLOAT_PRECISION);
+bool			equals(double a, double b, double precision = DOUBLE_PRECISION);
+
+bool			test_bitmask(int value, int bitmask);	//!< Tests agains a specified bitmask and returns true only if all bits are satisfied
+int				set_bitmask(int value, int bitmask);	//!< Sets the specified bitmask
+int				unset_bitmask(int value, int bitmask);	//!< Removes the specified bitmask
+
+
+template <typename T> T		min(const T& a, const T& b);	//!< Returns minimum between two values
+template <typename T> T		max(const T& a, const T& b);	//!< Returns maximum between two values
+template <typename T> T		avg(const T& a, const T& b);	//!< Returns the arithmetic mean of a and b
+template <typename T> T		clamp_to_range(const T& min, const T& max, const T& value);	//!< Clamps a value to a specific range (min < max)
+template <typename T> void	swap(T& a, T& b);				//!< Swaps @a and @b
+
+real			deg_to_rad(real deg);			//!< Returns "deg" in radians
+real			rad_to_deg(real rad);			//!< Returns "rad" in degrees
+uint			next_pow_2(uint x);				//!< Returns the nearest power of two to @x
+bool			is_pow_2(uint x);				//!< Returns whether @x is power of two
+real			ceil(real x);					//!< Returns the smallest integral value that is not less than x
+real			floor(real x);					//!< Returns the largest integral value that is not greater than x
+real			sqrt(real x);					//!< Returns the square root of @x
+real			inv_sqrt(real x);				//!< Returns the inverse square root of @x
+real			sin(real x);					//!< Returns the sine of @x
+real			cos(real x);					//!< Returns the cosine of @x
+real			asin(real x);					//!< Returns the arc sine of @x
+real			acos(real x);					//!< Returns the arc cosine of @x
+real			tan(real x);					//!< Returns the tangent of @x
+real			atan2(real y, real x);			//!< Returns the arc tangent of @y/@x
+real			abs(real x);					//!< Returns the absolute value of @x
+real			fmod(real n, real d);			//!< Returns the realing-point remainder of numerator/denominator
+
+
+				//! Returns true if there are solutions and puts them in 'x1' and 'x2' (x1 <= x2)
+bool			solve_quadratic_equation(real a, real b, real c, real& x1, real& x2);
 
 //-----------------------------------------------------------------------------
-inline bool Math::Equals(float a, float b, float precision)
+inline bool equals(float a, float b, float precision)
 {
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Math::Equals(double a, double b, double precision)
+inline bool equals(double a, double b, double precision)
 {
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Math::TestBitmask(int value, int bitmask)
+inline bool test_bitmask(int value, int bitmask)
 {
 	return (value & bitmask) == bitmask;
 }
 
 //-----------------------------------------------------------------------------
-inline int Math::SetBitmask(int value, int bitmask)
+inline int set_bitmask(int value, int bitmask)
 {
 	return value | bitmask;
 }
 
 //-----------------------------------------------------------------------------
-inline int Math::UnsetBitmask(int value, int bitmask)
+inline int unset_bitmask(int value, int bitmask)
 {
 	return value & (~bitmask);
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Math::Min(const T& a, const T& b)
+inline T min(const T& a, const T& b)
 {
 	return a < b ? a : b;
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Math::Max(const T& a, const T& b)
+inline T max(const T& a, const T& b)
 {
 	return a < b ? b : a;
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Math::Avg(const T& a, const T& b)
+inline T avg(const T& a, const T& b)
 {
 	return (a + b) * 0.5;
 }
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline T Math::ClampToRange(const T& min, const T& max, const T& value)
+inline T clamp_to_range(const T& min, const T& max, const T& value)
 {
 	assert(min < max);
 
@@ -190,7 +166,7 @@ inline T Math::ClampToRange(const T& min, const T& max, const T& value)
 
 //-----------------------------------------------------------------------------
 template <typename T>
-inline void Math::Swap(T& a, T& b)
+inline void swap(T& a, T& b)
 {
 	T tmp = a;
 	a = b;
@@ -198,19 +174,19 @@ inline void Math::Swap(T& a, T& b)
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::DegToRad(real deg)
+inline real deg_to_rad(real deg)
 {
-	return deg * Math::DEG_TO_RAD;
+	return deg * DEG_TO_RAD;
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::RadToDeg(real rad)
+inline real rad_to_deg(real rad)
 {
-	return rad * Math::RAD_TO_DEG;
+	return rad * RAD_TO_DEG;
 }
 
 //-----------------------------------------------------------------------------
-inline uint Math::NextPow2(uint x)
+inline uint next_pow_2(uint x)
 {
 	x--;
 
@@ -224,85 +200,85 @@ inline uint Math::NextPow2(uint x)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Math::IsPow2(uint x)
+inline bool is_pow_2(uint x)
 {
 	return !(x & (x - 1)) && x;
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Ceil(real x)
+inline real ceil(real x)
 {
 	return ceilf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Floor(real x)
+inline real floor(real x)
 {
 	return floorf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Sqrt(real x)
+inline real sqrt(real x)
 {
 	return sqrtf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::InvSqrt(real x)
+inline real inv_sqrt(real x)
 {
-	return 1.0 / Math::Sqrt(x);
+	return 1.0 / sqrt(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Sin(real x)
+inline real sin(real x)
 {
 	return sinf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Cos(real x)
+inline real cos(real x)
 {
 	return cosf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Asin(real x)
+inline real asin(real x)
 {
 	return asinf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Acos(real x)
+inline real acos(real x)
 {
 	return acosf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Tan(real x)
+inline real tan(real x)
 {
 	return tanf(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Atan2(real y, real x)
+inline real atan2(real y, real x)
 {
 	return atan2f(y, x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::Abs(real x)
+inline real abs(real x)
 {
 	return fabs(x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Math::FMod(real n, real d)
+inline real fmod(real n, real d)
 {
-	return fmod(n, d);
+	return ::fmod(n, d);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Math::SolveQuadraticEquation(real a, real b, real c, real& x1, real& x2)
+inline bool solve_quadratic_equation(real a, real b, real c, real& x1, real& x2)
 {
 	real delta = (b * b) - (4.0 * a * c);
 
@@ -312,16 +288,17 @@ inline bool Math::SolveQuadraticEquation(real a, real b, real c, real& x1, real&
 		return false;
 	}
 
-	x1 = (-b + Math::Sqrt(delta)) / (2.0 * a);
-	x2 = (-b - Math::Sqrt(delta)) / (2.0 * a);
+	x1 = (-b + sqrt(delta)) / (2.0 * a);
+	x2 = (-b - sqrt(delta)) / (2.0 * a);
 
 	if (x2 > x1)
 	{
-		Swap(x1, x2);
+		swap(x1, x2);
 	}
 
 	return true;
 }
 
+} // namespace math
 } // namespace Crown
 

+ 7 - 7
src/core/math/Plane.cpp

@@ -56,11 +56,11 @@ Plane::~Plane()
 }
 
 //-----------------------------------------------------------------------------
-Plane& Plane::Normalize()
+Plane& Plane::normalize()
 {
-	real len = n.GetLength();
+	real len = n.length();
 
-	if (Math::Equals(len, (real)0.0))
+	if (math::equals(len, (real)0.0))
 	{
 		return *this;
 	}
@@ -74,15 +74,15 @@ Plane& Plane::Normalize()
 }
 
 //-----------------------------------------------------------------------------
-real Plane::GetDistanceToPoint(const Vec3& p) const
+real Plane::get_distance_to_point(const Vec3& p) const
 {
-	return n.Dot(p) + d;
+	return n.dot(p) + d;
 }
 
 //-----------------------------------------------------------------------------
-bool Plane::ContainsPoint(const Vec3& p) const
+bool Plane::contains_point(const Vec3& p) const
 {
-	return Math::Equals(n.Dot(p) + d, (real)0.0);
+	return math::equals(n.dot(p) + d, (real)0.0);
 }
 
 } // namespace Crown

+ 3 - 4
src/core/math/Plane.h

@@ -40,7 +40,6 @@ namespace Crown
 */
 class Plane
 {
-
 public:
 
 	Vec3				n;
@@ -51,10 +50,10 @@ public:
 						Plane(const Vec3& normal, real dist);		//!< Constructs from a normal and distance factor
 						~Plane();									//!< Destructor
 
-	Plane&				Normalize();								//!< Normalizes the plane
+	Plane&				normalize();								//!< Normalizes the plane
 
-	real				GetDistanceToPoint(const Vec3& p) const;	//!< Returns the signed distance between point "p" and the plane
-	bool				ContainsPoint(const Vec3& p) const;			//!< Returns whether the plane contains the point
+	real				get_distance_to_point(const Vec3& p) const;	//!< Returns the signed distance between point "p" and the plane
+	bool				contains_point(const Vec3& p) const;		//!< Returns whether the plane contains the point
 
 	static const Plane	ZERO;
 	static const Plane	XAXIS;

+ 27 - 51
src/core/math/Point2.h

@@ -40,7 +40,6 @@ namespace Crown
 */
 class Point2
 {
-
 public:
 
 	int						x, y;
@@ -62,7 +61,7 @@ public:
 	Point2&					operator*=(int k);					//! Multiplication by scalar
 	Point2					operator/(int k) const;				//! Division by scalar
 	Point2&					operator/=(int k);					//! Division by scalar
-	int						Dot(const Point2& a);				//! Dot product
+	int						dot(const Point2& a);				//! dot product
 
 	friend Point2			operator*(int k, const Point2& a);	//! For simmetry
 
@@ -71,22 +70,22 @@ public:
 	bool					operator<(const Point2& other) const;	//! Returns whether all the components of this point are smaller than all of the "other" point
 	bool					operator>(const Point2& other) const;	//! Returns whether all the components of this point are greater than all of the "other" point
 
-	real					GetLength() const;					//! Returns the point's length
-	int						GetSquaredLength() const;			//! Returns the point's squared length
-	void					Negate();							//! Negates the point (i.e. builds the inverse)
+	real					length() const;						//! Returns the point's length
+	int						squared_length() const;				//! Returns the point's squared length
+	void					negate();							//! Negates the point (i.e. builds the inverse)
 
-	real					GetDistanceTo(const Point2& a);		//!< Returns the distance
-	real					GetAngleBetween(const Point2& a);	//!< Returns the angle in radians
+	real					get_distance_to(const Point2& a);	//!< Returns the distance
+	real					get_angle_between(const Point2& a);	//!< Returns the angle in radians
 
 	Point2					operator-() const;					//! Negates the point (i.e. builds the inverse)
 
-	void					Zero();								//! Builds the zero point
+	void					zero();								//! Builds the zero point
 
-	int*					ToIntPtr();	//! Returns the pointer to the point's data
-	const int*				ToIntPtr() const;	//! Returns the pointer to the point's data
-	Vec2					ToVec2() const;	//! Returns a vector from this point
-	Vec3					ToVec3() const;	//! Returns a vector from this point
-	Str						ToStr() const;	//! Returns a Str containing the point's components
+	int*					to_int_ptr();		//! Returns the pointer to the point's data
+	const int*				to_int_ptr() const;	//! Returns the pointer to the point's data
+	Vec2					to_vec2() const;	//! Returns a vector from this point
+	Vec3					to_vec3() const;	//! Returns a vector from this point
+	Str						to_str() const;		//! Returns a Str containing the point's components
 
 	static const Point2		ZERO;
 	static const Point2		ONE;
@@ -200,7 +199,7 @@ inline Point2& Point2::operator/=(int k)
 }
 
 //-----------------------------------------------------------------------------
-inline int Point2::Dot(const Point2& a)
+inline int Point2::dot(const Point2& a)
 {
 	return x * a.x + y * a.y;
 }
@@ -237,34 +236,34 @@ inline bool Point2::operator>(const Point2& other) const
 }
 
 //-----------------------------------------------------------------------------
-inline real Point2::GetLength() const
+inline real Point2::length() const
 {
-	return Math::Sqrt((real)(x * x + y * y));
+	return math::acos((real)(x * x + y * y));
 }
 
 //-----------------------------------------------------------------------------
-inline int Point2::GetSquaredLength() const
+inline int Point2::squared_length() const
 {
 	return x * x + y * y;
 }
 
 //-----------------------------------------------------------------------------
-inline void Point2::Negate()
+inline void Point2::negate()
 {
 	x = -x;
 	y = -y;
 }
 
 //-----------------------------------------------------------------------------
-inline real Point2::GetDistanceTo(const Point2& a)
+inline real Point2::get_distance_to(const Point2& a)
 {
-	return (*this - a).GetLength();
+	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline real Point2::GetAngleBetween(const Point2& a)
+inline real Point2::get_angle_between(const Point2& a)
 {
-	return Math::Acos(this->Dot(a) / (this->GetLength() * a.GetLength()));
+	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
@@ -274,37 +273,37 @@ inline Point2 Point2::operator-() const
 }
 
 //-----------------------------------------------------------------------------
-inline void Point2::Zero()
+inline void Point2::zero()
 {
 	x = y = 0;
 }
 
 //-----------------------------------------------------------------------------
-inline int* Point2::ToIntPtr()
+inline int* Point2::to_int_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const int* Point2::ToIntPtr() const
+inline const int* Point2::to_int_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Point2::ToVec2() const
+inline Vec2 Point2::to_vec2() const
 {
 	return Vec2((real)x, (real)y);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Point2::ToVec3() const
+inline Vec3 Point2::to_vec3() const
 {
 	return Vec3((real)x, (real)y, 0.0);
 }
 
 //-----------------------------------------------------------------------------
-inline Str Point2::ToStr() const
+inline Str Point2::to_str() const
 {
 	Str tmp;
 
@@ -313,28 +312,5 @@ inline Str Point2::ToStr() const
 	return tmp;
 }
 
-//-----------------------------------------------------------------------------
-inline bool DeserializeFromStr(Point2& out, Str& input)
-{
-	List<Str> coords;
-	input.Split(',', coords);
-
-	if (coords.GetSize() != 2)
-		return false;
-
-	if (!coords[0].ParseInt(&out.x))
-		return false;
-	if (!coords[1].ParseInt(&out.y))
-		return false;
-
-	return true;
-}
-
-//-----------------------------------------------------------------------------
-inline Str SerializeToStr(const Point2& in)
-{
-	return Str(in.x) + ", " + Str(in.y);
-}
-
 } // namespace Crown
 

+ 29 - 29
src/core/math/Quat.cpp

@@ -40,15 +40,15 @@ Quat::Quat()
 
 Quat::Quat(real angle, const Vec3& v)
 {
-	this->w = Math::Cos((real)(angle * 0.5));
-	this->v = v * Math::Sin((real)(angle * 0.5));
+	this->w = math::cos((real)(angle * 0.5));
+	this->v = v * math::sin((real)(angle * 0.5));
 }
 
 Quat::~Quat()
 {
 }
 
-Str Quat::ToStr() const
+Str Quat::to_str() const
 {
 	Str tmp;
 
@@ -57,13 +57,13 @@ Str Quat::ToStr() const
 	return tmp;
 }
 
-void Quat::Negate()
+void Quat::negate()
 {
 	w = -w;
-	v.Negate();
+	v.negate();
 }
 
-void Quat::LoadIdentity()
+void Quat::load_identity()
 {
 	w = 1.0;
 	v.x = 0.0;
@@ -71,32 +71,32 @@ void Quat::LoadIdentity()
 	v.z = 0.0;
 }
 
-real Quat::GetLength() const
+real Quat::length() const
 {
-	return Math::Sqrt(w * w + v.x * v.x + v.y * v.y + v.z * v.z);
+	return math::sqrt(w * w + v.x * v.x + v.y * v.y + v.z * v.z);
 }
 
-void Quat::Conjugate()
+void Quat::conjugate()
 {
 	v = -v;
 }
 
-Quat Quat::GetConjugate() const
+Quat Quat::get_conjugate() const
 {
 	return Quat(w, -v);
 }
 
-Quat Quat::GetInverse() const
+Quat Quat::get_inverse() const
 {
-	return GetConjugate() * ((real)(1.0 / GetLength()));
+	return get_conjugate() * ((real)(1.0 / length()));
 }
 
-Angles Quat::ToAngles() const
+Angles Quat::to_angles() const
 {
-	return ToMat4().ToAngles();
+	return to_mat4().to_angles();
 }
 
-Mat3 Quat::ToMat3() const
+Mat3 Quat::to_mat3() const
 {
 	Mat3 tmp;
 	real x = v.x;
@@ -116,7 +116,7 @@ Mat3 Quat::ToMat3() const
 	return tmp;
 }
 
-Mat4 Quat::ToMat4() const
+Mat4 Quat::to_mat4() const
 {
 	Mat4 tmp;
 	real x = v.x;
@@ -143,13 +143,13 @@ Mat4 Quat::ToMat4() const
 	return tmp;
 }
 
-// Cross product
+// cross product
 Quat Quat::operator*(const Quat& b) const
 {
 	Quat tmp;
 
-	tmp.w = w * b.w - v.Dot(b.v);
-	tmp.v = w * b.v + b.w * v + b.v.Cross(v);
+	tmp.w = w * b.w - v.dot(b.v);
+	tmp.v = w * b.v + b.w * v + b.v.cross(v);
 
 	return tmp;
 }
@@ -165,16 +165,16 @@ Quat Quat::operator*(const real& k) const
 	return tmp;
 }
 
-Quat Quat::Power(real exp)
+Quat Quat::power(real exp)
 {
 	Quat tmp;
 
-	if (Math::Abs(w) < 0.9999)
+	if (math::abs(w) < 0.9999)
 	{
-		real alpha = Math::Acos(w); // alpha = theta/2
+		real alpha = math::acos(w); // alpha = theta/2
 		real newAlpha = alpha * exp;
-		tmp.w = Math::Cos(newAlpha);
-		real mult = Math::Sin(newAlpha) / Math::Sin(alpha);
+		tmp.w = math::cos(newAlpha);
+		real mult = math::sin(newAlpha) / math::sin(alpha);
 		tmp.v.x = v.x * mult;
 		tmp.v.y = v.y * mult;
 		tmp.v.z = v.z * mult;
@@ -192,16 +192,16 @@ The geometric interpretation of the Quat dot product is similar to the interpret
 the vector dot product; the larger the absolute value of the Quat dot product axb, the more
 "similar" the angular displacements represented by a and b.
 */
-real Dot(const Quat& a, const Quat& b)
+real dot(const Quat& a, const Quat& b)
 {
-	return a.w * b.w + a.v.Dot(b.v);
+	return a.w * b.w + a.v.dot(b.v);
 }
 
 // Spherical Linear intERPolation
-Quat Slerp(const Quat& start, const Quat& end, real t)
+Quat slerp(const Quat& start, const Quat& end, real t)
 {
-	Quat delta = end * start.GetInverse();
-	delta = delta.Power(t);
+	Quat delta = end * start.get_inverse();
+	delta = delta.power(t);
 
 	return delta * start;
 }

+ 11 - 12
src/core/math/Quat.h

@@ -50,7 +50,6 @@ class Mat4;
 */
 class Quat
 {
-
 public:
 
 	Vec3		v;
@@ -60,23 +59,23 @@ public:
 				Quat(real angle, const Vec3& v);	//!< Builds the quaternion from an angle and a vector
 				~Quat();							//!< Destructor
 
-	void		Negate();							//!< Negates the quaternion
-	void		LoadIdentity();						//!< Builds the identity quaternion
-	real		GetLength() const;					//!< Returns the quaternion's length
-	void		Conjugate();						//!< Conjugates the quaternion
-	Quat		GetConjugate() const;				//!< Returns the quaternion's conjugate
-	Quat		GetInverse() const;					//!< Quaternion's inverse
+	void		negate();							//!< Negates the quaternion
+	void		load_identity();					//!< Builds the identity quaternion
+	real		length() const;						//!< Returns the quaternion's length
+	void		conjugate();						//!< Conjugates the quaternion
+	Quat		get_conjugate() const;				//!< Returns the quaternion's conjugate
+	Quat		get_inverse() const;				//!< Quaternion's inverse
 
-	Angles		ToAngles() const;
-	Mat3		ToMat3() const;
-	Mat4		ToMat4() const;
+	Angles		to_angles() const;
+	Mat3		to_mat3() const;
+	Mat4		to_mat4() const;
 
 	Quat		operator*(const Quat& b) const;		//!< Cross product
 	Quat		operator*(const real& k) const;		//!< Multiplication by a scalar
 
-	Quat		Power(real exp);
+	Quat		power(real exp);
 
-	Str			ToStr() const;						//!< Returns a Str containing the quaternion's components
+	Str			to_str() const;						//!< Returns a Str containing the quaternion's components
 };
 
 } // namespace Crown

+ 8 - 9
src/core/math/Random.h

@@ -35,14 +35,13 @@ namespace Crown
 */ 
 class Random
 {
-
 public:
 
 			Random(int seed);	//!< Constructor
 
-	int		GetInt();			//!< Returns a pseudo-random integer in the range [0, 32767]
-	int		GetInt(int max);	//!< Returns a pseudo-random integer in the range [0, max)
-	float	GetUnitFloat();		//!< Returns a pseudo-random unit float in the range [0.0, 1.0].
+	int		get_int();			//!< Returns a pseudo-random integer in the range [0, 32767]
+	int		get_int(int max);	//!< Returns a pseudo-random integer in the range [0, max)
+	float	get_unit_float();	//!< Returns a pseudo-random float in the range [0.0, 1.0].
 
 private:
 
@@ -55,7 +54,7 @@ inline Random::Random(int seed) : mSeed(seed)
 }
 
 //-----------------------------------------------------------------------------
-inline int Random::GetInt()
+inline int Random::get_int()
 {
 	mSeed = 214013 * mSeed + 13737667;
 
@@ -63,15 +62,15 @@ inline int Random::GetInt()
 }
 
 //-----------------------------------------------------------------------------
-inline int Random::GetInt(int max)
+inline int Random::get_int(int max)
 {
-	return (max == 0) ? 0 : GetInt() % max;
+	return (max == 0) ? 0 : get_int() % max;
 }
 
 //-----------------------------------------------------------------------------
-inline float Random::GetUnitFloat()
+inline float Random::get_unit_float()
 {
-	return GetInt() / (float) 0x7FFF;
+	return get_int() / (float) 0x7FFF;
 }
 
 } // namespace Crown

+ 0 - 1
src/core/math/Ray.h

@@ -41,7 +41,6 @@ namespace Crown
 */
 class Ray
 {
-
 public:
 
 	Vec3	origin;

+ 20 - 20
src/core/math/Shape.cpp

@@ -23,23 +23,23 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Shape.h"
-
-namespace Crown
-{
-
-Shape::Shape(ShapeType type):
-	mType(type)
-{
-}
-
-Shape::~Shape()
-{
-}
-
-ShapeType Shape::GetShapeType()
-{
-	return mType;
-}
-
-}
+#include "Shape.h"
+
+namespace Crown
+{
+
+Shape::Shape(ShapeType type):
+	mType(type)
+{
+}
+
+Shape::~Shape()
+{
+}
+
+ShapeType Shape::get_shape_type()
+{
+	return mType;
+}
+
+}

+ 1 - 1
src/core/math/Shape.h

@@ -53,7 +53,7 @@ public:
 					Shape(ShapeType type);
 					~Shape();
 
-	ShapeType		GetShapeType();
+	ShapeType		get_shape_type();
 
 private:
 

+ 20 - 21
src/core/math/Triangle.h

@@ -39,7 +39,6 @@ namespace Crown
 */
 class Triangle
 {
-
 public:
 
 	Vec3		v1, v2, v3;				//!< Vertices, CCW order
@@ -48,13 +47,13 @@ public:
 				Triangle(const Vec3& nv1, const Vec3& nv2, const Vec3& nv3);	//!< Constructor
 				~Triangle();			//!< Destructor
 
-	real		GetArea() const;		//!< Returns the area
-	Vec3		GetCentroid() const;	//!< Returns the center of gravity (a.k.a. centroid.)
-	Vec3		GetBarycentricCoords(const Vec3& p) const;	//!< Returns the barycentric coordinates of point "p"
+	real		get_area() const;		//!< Returns the area
+	Vec3		get_centroid() const;	//!< Returns the center of gravity (a.k.a. centroid.)
+	Vec3		get_barycentric_coords(const Vec3& p) const;	//!< Returns the barycentric coordinates of point "p"
 
-	bool		ContainsPoint(const Vec3& p) const;		//!< Returns whether the triangle contains the "p" point
+	bool		contains_point(const Vec3& p) const;		//!< Returns whether the triangle contains the "p" point
 
-	Plane		ToPlane() const;		//!< Returns the plane containing the triangle
+	Plane		to_plane() const;		//!< Returns the plane containing the triangle
 };
 
 //-----------------------------------------------------------------------------
@@ -73,19 +72,19 @@ inline Triangle::~Triangle()
 }
 
 //-----------------------------------------------------------------------------
-inline real Triangle::GetArea() const
+inline real Triangle::get_area() const
 {
-	return ((v2 - v1).Cross(v3 - v1)).GetLength() * (real)0.5;
+	return ((v2 - v1).cross(v3 - v1)).length() * (real)0.5;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::GetCentroid() const
+inline Vec3 Triangle::get_centroid() const
 {
-	return (v1 + v2 + v3) * Math::ONE_OVER_THREE;
+	return (v1 + v2 + v3) * math::ONE_OVER_THREE;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::GetBarycentricCoords(const Vec3& p) const
+inline Vec3 Triangle::get_barycentric_coords(const Vec3& p) const
 {
 //	Vec3 e1 = v1 - v3;
 //	Vec3 e2 = v2 - v1;
@@ -99,14 +98,14 @@ inline Vec3 Triangle::GetBarycentricCoords(const Vec3& p) const
 	Vec3 d2 = p - v2;
 	Vec3 d3 = p - v3;
 
-	Vec3 n = e1.Cross(e2) / e1.Cross(e2).GetLength();
+	Vec3 n = e1.cross(e2) / e1.cross(e2).length();
 
 	// Signed areas
-	real at = (real)(e1.Cross(e2).Dot(n) * 0.5);
+	real at = (real)(e1.cross(e2).dot(n) * 0.5);
 
-	real at1 = (real)(e1.Cross(d3).Dot(n) * 0.5);
-	real at2 = (real)(e2.Cross(d1).Dot(n) * 0.5);
-	real at3 = (real)(e3.Cross(d2).Dot(n) * 0.5);
+	real at1 = (real)(e1.cross(d3).dot(n) * 0.5);
+	real at2 = (real)(e2.cross(d1).dot(n) * 0.5);
+	real at3 = (real)(e3.cross(d2).dot(n) * 0.5);
 
 	real oneOverAt = (real)(1.0 / at);
 
@@ -114,9 +113,9 @@ inline Vec3 Triangle::GetBarycentricCoords(const Vec3& p) const
 }
 
 //-----------------------------------------------------------------------------
-inline bool Triangle::ContainsPoint(const Vec3& p) const
+inline bool Triangle::contains_point(const Vec3& p) const
 {
-	Vec3 bc = GetBarycentricCoords(p);
+	Vec3 bc = get_barycentric_coords(p);
 
 	if (bc.x < 0.0 || bc.y < 0.0 || bc.z < 0.0)
 	{
@@ -127,13 +126,13 @@ inline bool Triangle::ContainsPoint(const Vec3& p) const
 }
 
 //-----------------------------------------------------------------------------
-inline Plane Triangle::ToPlane() const
+inline Plane Triangle::to_plane() const
 {
 	Vec3 e1 = v3 - v2;
 	Vec3 e2 = v2 - v1;
 
-	Vec3 n = e2.Cross(e1).Normalize();
-	real d = -n.Dot(v1);
+	Vec3 n = e2.cross(e1).normalize();
+	real d = -n.dot(v1);
 
 	return Plane(n, d);
 }

+ 48 - 72
src/core/math/Vec2.h

@@ -36,7 +36,6 @@ namespace Crown
 //!< 2D column vector
 class Vec2
 {
-
 public:
 
 	real				x, y;
@@ -59,7 +58,7 @@ public:
 	Vec2&				operator*=(real k);						//!< Multiplication by scalar
 	Vec2				operator/(real k) const;				//!< Division by scalar
 	Vec2&				operator/=(real k);						//!< Division by scalar
-	real				Dot(const Vec2& a) const;				//!< Dot product
+	real				dot(const Vec2& a) const;				//!< dot product
 
 	friend Vec2			operator*(real k, const Vec2& a);		//!< For simmetry
 
@@ -68,24 +67,24 @@ public:
 	bool				operator<(const Vec2& other) const;		//!< Returns whether all the components of this vector are smaller than all of the "other" vector
 	bool				operator>(const Vec2& other) const;		//!< Returns whether all the components of this vector are greater than all of the "other" vector
 
-	real				GetLength() const;						//!< Returns the vector's length
-	real				GetSquaredLength() const;				//!< Returns the vector's squared length
-	void				SetLength(real len);					//!< Sets the vector's length
-	real				GetAngle() const;
-	real				GetAngle2d() const;
-	Vec2&				Normalize();							//!< Normalizes the vector
-	Vec2				GetNormalized() const;					//!< Returns the normalized vector
-	Vec2&				Negate();								//!< Negates the vector (i.e. builds the inverse)
+	real				length() const;						//!< Returns the vector's length
+	real				squared_length() const;				//!< Returns the vector's squared length
+	void				set_length(real len);					//!< Sets the vector's length
+	real				get_angle() const;
+	real				get_angle_2d() const;
+	Vec2&				normalize();							//!< Normalizes the vector
+	Vec2				get_normalized() const;					//!< Returns the normalized vector
+	Vec2&				negate();								//!< Negates the vector (i.e. builds the inverse)
 	Vec2				operator-() const;						//!< Negates the vector (i.e. builds the inverse)
 
-	real				GetDistanceTo(const Vec2& a) const;		//!< Returns the distance
-	real				GetAngleBetween(const Vec2& a) const;	//!< Returns the angle in radians
+	real				get_distance_to(const Vec2& a) const;		//!< Returns the distance
+	real				get_angle_between(const Vec2& a) const;	//!< Returns the angle in radians
 
-	void				Zero();									//!< Builds the zero vector
+	void				zero();									//!< Builds the zero vector
 
-	real*				ToFloatPtr();							//!< Returns the pointer to the vector's data
-	const real*			ToFloatPtr() const;						//!< Returns the pointer to the vector's data
-	Str					ToStr() const;							//!< Returns a Str containing the vector's components
+	real*				to_float_ptr();							//!< Returns the pointer to the vector's data
+	const real*			to_float_ptr() const;						//!< Returns the pointer to the vector's data
+	Str					to_str() const;							//!< Returns a Str containing the vector's components
 
 	static const Vec2	ZERO;
 	static const Vec2	ONE;
@@ -208,7 +207,7 @@ inline Vec2& Vec2::operator/=(real k)
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::Dot(const Vec2& a) const
+inline real Vec2::dot(const Vec2& a) const
 {
 	return x * a.x + y * a.y;
 }
@@ -216,13 +215,13 @@ inline real Vec2::Dot(const Vec2& a) const
 //-----------------------------------------------------------------------------
 inline bool Vec2::operator==(const Vec2& other) const
 {
-	return Math::Equals(x, other.x) && Math::Equals(y, other.y);
+	return math::equals(x, other.x) && math::equals(y, other.y);
 }
 
 //-----------------------------------------------------------------------------
 inline bool Vec2::operator!=(const Vec2& other) const
 {
-	return !Math::Equals(x, other.x) || !Math::Equals(y, other.y);
+	return !math::equals(x, other.x) || !math::equals(y, other.y);
 }
 
 //-----------------------------------------------------------------------------
@@ -238,64 +237,64 @@ inline bool Vec2::operator>(const Vec2& other) const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetLength() const
+inline real Vec2::length() const
 {
-	return Math::Sqrt(x * x + y * y);
+	return math::sqrt(x * x + y * y);
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetSquaredLength() const
+inline real Vec2::squared_length() const
 {
 	return x * x + y * y;
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec2::SetLength(real len)
+inline void Vec2::set_length(real len)
 {
-	Normalize();
+	normalize();
 
 	x *= len;
 	y *= len;
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetAngle() const
+inline real Vec2::get_angle() const
 {
-	return Math::Atan2(y, x);
+	return math::atan2(y, x);
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetAngle2d() const
+inline real Vec2::get_angle_2d() const
 {
-	return Math::Atan2(-y, x);
+	return math::atan2(-y, x);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::Normalize()
+inline Vec2& Vec2::normalize()
 {
-	real length = GetLength();
+	real len = length();
 
-	if (Math::Equals(length, (real)0.0))
+	if (math::equals(len, (real)0.0))
 	{
 		return *this;
 	}
 
-	x /= length;
-	y /= length;
+	x /= len;
+	y /= len;
 
 	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::GetNormalized() const
+inline Vec2 Vec2::get_normalized() const
 {
 	Vec2 tmp(x, y);
 
-	return tmp.Normalize();
+	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::Negate()
+inline Vec2& Vec2::negate()
 {
 	x = -x;
 	y = -y;
@@ -310,38 +309,38 @@ inline Vec2 Vec2::operator-() const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetDistanceTo(const Vec2& a) const
+inline real Vec2::get_distance_to(const Vec2& a) const
 {
-	return (*this - a).GetLength();
+	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec2::GetAngleBetween(const Vec2& a) const
+inline real Vec2::get_angle_between(const Vec2& a) const
 {
-	return Math::Acos(this->Dot(a) / (this->GetLength() * a.GetLength()));
+	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec2::Zero()
+inline void Vec2::zero()
 {
 	x = 0.0;
 	y = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-inline real* Vec2::ToFloatPtr()
+inline real* Vec2::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const real* Vec2::ToFloatPtr() const
+inline const real* Vec2::to_float_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Str Vec2::ToStr() const
+inline Str Vec2::to_str() const
 {
 	Str tmp;
 
@@ -351,19 +350,19 @@ inline Str Vec2::ToStr() const
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 GetProjectedParallel(const Vec2& v, const Vec2& n)
+inline Vec2 get_projected_parallel(const Vec2& v, const Vec2& n)
 {
 	real n_len_q;
-	n_len_q = n.GetLength();
+	n_len_q = n.length();
 	n_len_q = n_len_q * n_len_q;
 
-	return n * (v.Dot(n) / n_len_q);
+	return n * (v.dot(n) / n_len_q);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 GetProjectedPerpendicular(const Vec2& v, const Vec2& n)
+inline Vec2 get_projected_perpendicular(const Vec2& v, const Vec2& n)
 {
-	return v - GetProjectedParallel(v, n);
+	return v - get_projected_parallel(v, n);
 }
 
 //-----------------------------------------------------------------------------
@@ -372,28 +371,5 @@ inline Vec2 operator*(real k, const Vec2& a)
 	return a * k;
 }
 
-//-----------------------------------------------------------------------------
-inline bool DeserializeFromStr(Vec2& out, Str& input)
-{
-	List<Str> coords;
-	input.Split(',', coords);
-
-	if (coords.GetSize() != 2)
-		return false;
-
-	if (!coords[0].ParseFloat(&out.x))
-		return false;
-	if (!coords[1].ParseFloat(&out.y))
-		return false;
-
-	return true;
-}
-
-//-----------------------------------------------------------------------------
-inline Str SerializeToStr(const Vec2& in)
-{
-	return Str(in.x) + ", " + Str(in.y);
-}
-
 } // namespace Crown
 

+ 51 - 50
src/core/math/Vec3.h

@@ -34,10 +34,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace Crown
 {
 
-//!< 3D column vector
+/**
+	3D column vector.
+*/
 class Vec3
 {
-
 public:
 
 	real				x, y, z;
@@ -60,8 +61,8 @@ public:
 	Vec3&				operator*=(real k);						//!< Multiplication by scalar
 	Vec3				operator/(real k) const;				//!< Division by scalar
 	Vec3&				operator/=(real k);						//!< Division by scalar
-	real				Dot(const Vec3& a) const;				//!< Dot product
-	Vec3				Cross(const Vec3& a) const;				//!< Cross product
+	real				dot(const Vec3& a) const;				//!< dot product
+	Vec3				cross(const Vec3& a) const;				//!< cross product
 
 	friend Vec3			operator*(real k, const Vec3& a);		//!< For simmetry
 
@@ -70,23 +71,23 @@ public:
 	bool				operator<(const Vec3& other) const;		//!< Returns whether all the components of this vector are smaller than all of the "other" vector
 	bool				operator>(const Vec3& other) const;		//!< Returns whether all the components of this vector are greater than all of the "other" vector
 
-	real				GetLength() const;						//!< Returns the vector's length
-	real				GetSquaredLength() const;				//!< Returns the vector's squared length
-	void				SetLength(real len);					//!< Sets the vector's length
-	Vec3&				Normalize();							//!< Normalizes the vector
-	Vec3				GetNormalized() const;					//!< Returns the normalized vector
-	Vec3&				Negate();								//!< Negates the vector (i.e. builds the inverse)
+	real				length() const;							//!< Returns the vector's length
+	real				squared_length() const;					//!< Returns the vector's squared length
+	void				set_length(real len);					//!< Sets the vector's length
+	Vec3&				normalize();							//!< Normalizes the vector
+	Vec3				get_normalized() const;					//!< Returns the normalized vector
+	Vec3&				negate();								//!< Negates the vector (i.e. builds the inverse)
 	Vec3				operator-() const;						//!< Negates the vector (i.e. builds the inverse)
 
-	real				GetDistanceTo(const Vec3& a) const;		//!< Returns the distance
-	real				GetAngleBetween(const Vec3& a) const;	//!< Returns the angle in radians
+	real				get_distance_to(const Vec3& a) const;	//!< Returns the distance
+	real				get_angle_between(const Vec3& a) const;	//!< Returns the angle in radians
 
-	void				Zero();									//!< Builds the zero vector
+	void				zero();									//!< Builds the zero vector
 
-	real*				ToFloatPtr();							//!< Returns the pointer to the vector's data
-	const real*			ToFloatPtr() const;						//!< Returns the pointer to the vector's data
-	Vec2				ToVec2() const;							//!< Returns a Vec2 with only x and y coordinates
-	Str					ToStr() const;							//!< Returns a Str containing the vector's components
+	real*				to_float_ptr();							//!< Returns the pointer to the vector's data
+	const real*			to_float_ptr() const;					//!< Returns the pointer to the vector's data
+	Vec2				to_vec2() const;						//!< Returns a Vec2 with only x and y coordinates
+	Str					to_str() const;							//!< Returns a Str containing the vector's components
 
 	static const Vec3	ZERO;
 	static const Vec3	ONE;
@@ -214,13 +215,13 @@ inline Vec3& Vec3::operator/=(real k)
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec3::Dot(const Vec3& a) const
+inline real Vec3::dot(const Vec3& a) const
 {
 	return x * a.x + y * a.y + z * a.z;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::Cross(const Vec3& a) const
+inline Vec3 Vec3::cross(const Vec3& a) const
 {
 	return Vec3(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x);
 }
@@ -234,13 +235,13 @@ inline Vec3 operator*(real k, const Vec3& a)
 //-----------------------------------------------------------------------------
 inline bool Vec3::operator==(const Vec3& other) const
 {
-	return Math::Equals(x, other.x) && Math::Equals(y, other.y) && Math::Equals(z, other.z);
+	return math::equals(x, other.x) && math::equals(y, other.y) && math::equals(z, other.z);
 }
 
 //-----------------------------------------------------------------------------
 inline bool Vec3::operator!=(const Vec3& other) const
 {
-	return !Math::Equals(x, other.x) || !Math::Equals(y, other.y) || !Math::Equals(z, other.z);
+	return !math::equals(x, other.x) || !math::equals(y, other.y) || !math::equals(z, other.z);
 }
 
 //-----------------------------------------------------------------------------
@@ -256,21 +257,21 @@ inline bool Vec3::operator>(const Vec3& other) const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec3::GetLength() const
+inline real Vec3::length() const
 {
-	return Math::Sqrt(x * x + y * y + z * z);
+	return math::sqrt(x * x + y * y + z * z);
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec3::GetSquaredLength() const
+inline real Vec3::squared_length() const
 {
 	return x * x + y * y + z * z;
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec3::SetLength(real len)
+inline void Vec3::set_length(real len)
 {
-	Normalize();
+	normalize();
 
 	x *= len;
 	y *= len;
@@ -278,34 +279,34 @@ inline void Vec3::SetLength(real len)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::Normalize()
+inline Vec3& Vec3::normalize()
 {
-	real length = GetLength();
+	real len = length();
 
-	if (Math::Equals(length, (real)0.0))
+	if (math::equals(len, (real)0.0))
 	{
 		return *this;
 	}
 
-	length = (real)(1.0 / length); 
+	len = (real)(1.0 / len); 
 
-	x *= length;
-	y *= length;
-	z *= length;
+	x *= len;
+	y *= len;
+	z *= len;
 
 	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::GetNormalized() const
+inline Vec3 Vec3::get_normalized() const
 {
 	Vec3 tmp(x, y, z);
 
-	return tmp.Normalize();
+	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::Negate()
+inline Vec3& Vec3::negate()
 {
 	x = -x;
 	y = -y;
@@ -321,19 +322,19 @@ inline Vec3 Vec3::operator-() const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec3::GetDistanceTo(const Vec3& a) const
+inline real Vec3::get_distance_to(const Vec3& a) const
 {
-	return (*this - a).GetLength();
+	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec3::GetAngleBetween(const Vec3& a) const
+inline real Vec3::get_angle_between(const Vec3& a) const
 {
-	return Math::Acos(this->Dot(a) / (this->GetLength() * a.GetLength()));
+	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec3::Zero()
+inline void Vec3::zero()
 {
 	x = 0.0;
 	y = 0.0;
@@ -341,25 +342,25 @@ inline void Vec3::Zero()
 }
 
 //-----------------------------------------------------------------------------
-inline real* Vec3::ToFloatPtr()
+inline real* Vec3::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const real* Vec3::ToFloatPtr() const
+inline const real* Vec3::to_float_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec3::ToVec2() const
+inline Vec2 Vec3::to_vec2() const
 {
 	return Vec2(x, y);
 }
 
 //-----------------------------------------------------------------------------
-inline Str Vec3::ToStr() const
+inline Str Vec3::to_str() const
 {
 	Str tmp;
 
@@ -370,20 +371,20 @@ inline Str Vec3::ToStr() const
 
 //-----------------------------------------------------------------------------
 //!< Returns the parallel portion of "v" projected onto "n"
-inline Vec3 GetProjectedParallel(const Vec3& v, const Vec3& n)
+inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)
 {
 	real n_len_q;
-	n_len_q = n.GetLength();
+	n_len_q = n.length();
 	n_len_q = n_len_q * n_len_q;
 
-	return n * (v.Dot(n) / n_len_q);
+	return n * (v.dot(n) / n_len_q);
 }
 
 //-----------------------------------------------------------------------------
 //!< Returns the perpendicular portion of "v" projected onto "n"
-inline Vec3 GetProjectedPerpendicular(const Vec3& v, const Vec3& n)
+inline Vec3 get_projected_perpendicular(const Vec3& v, const Vec3& n)
 {
-	return v - GetProjectedParallel(v, n);
+	return v - get_projected_parallel(v, n);
 }
 
 } // namespace Crown

+ 41 - 40
src/core/math/Vec4.h

@@ -33,10 +33,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace Crown
 {
 
-//!< 4D column vector
+/**
+	4D column vector.
+*/
 class Vec4
 {
-
 public:
 
 	real				x, y, z, w;
@@ -59,7 +60,7 @@ public:
 	Vec4&				operator*=(real k);							//!< Multiplication by scalar
 	Vec4				operator/(real k) const;					//!< Division by scalar
 	Vec4&				operator/=(real k);							//!< Division by scalar
-	real				Dot(const Vec4& a) const;					//!< Dot product
+	real				dot(const Vec4& a) const;					//!< dot product
 
 	friend Vec4			operator*(real k, const Vec4& a);			//!< For simmetry
 
@@ -68,22 +69,22 @@ public:
 	bool				operator<(const Vec4& other) const;			//!< Returns whether all the components of this vector are smaller than all of the "other" vector
 	bool				operator>(const Vec4& other) const;			//!< Returns whether all the components of this vector are greater than all of the "other" vector
 
-	real				GetLength() const;							//!< Returns the vector's length
-	real				GetSquaredLength() const;					//!< Returns the vector's squared length
-	void				SetLength(real len);						//!< Sets the vector's length
-	Vec4&				Normalize();								//!< Normalizes the vector
-	Vec4				GetNormalized() const;						//!< Returns the normalized vector
-	Vec4&				Negate();									//!< Negates the vector (i.e. builds the inverse)
+	real				length() const;								//!< Returns the vector's length
+	real				squared_length() const;						//!< Returns the vector's squared length
+	void				set_length(real len);						//!< Sets the vector's length
+	Vec4&				normalize();								//!< Normalizes the vector
+	Vec4				get_normalized() const;						//!< Returns the normalized vector
+	Vec4&				negate();									//!< Negates the vector (i.e. builds the inverse)
 	Vec4				operator-() const;							//!< Negates the vector (i.e. builds the inverse)
 
-	real				GetDistanceTo(const Vec4& a) const;			//!< Returns the distance
-	real				GetAngleBetween(const Vec4& a) const;		//!< Returns the angle in radians
+	real				get_distance_to(const Vec4& a) const;		//!< Returns the distance
+	real				get_angle_between(const Vec4& a) const;		//!< Returns the angle in radians
 
-	void				Zero();										//!< Builds the zero vector
+	void				zero();										//!< Builds the zero vector
 
-	real*				ToFloatPtr();								//!< Returns the pointer to the vector's data
-	const real*			ToFloatPtr() const;							//!< Returns the pointer to the vector's data
-	Str					ToStr() const;								//!< Returns a Str containing the vector's components
+	real*				to_float_ptr();								//!< Returns the pointer to the vector's data
+	const real*			to_float_ptr() const;							//!< Returns the pointer to the vector's data
+	Str					to_str() const;								//!< Returns a Str containing the vector's components
 
 	static const Vec4	ZERO;
 	static const Vec4	ONE;
@@ -216,7 +217,7 @@ inline Vec4& Vec4::operator/=(real k)
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec4::Dot(const Vec4& a) const
+inline real Vec4::dot(const Vec4& a) const
 {
 	return x * a.x + y * a.y + z * a.z + w * a.w;
 }
@@ -230,13 +231,13 @@ inline Vec4 operator*(real k, const Vec4& a)
 //-----------------------------------------------------------------------------
 inline bool Vec4::operator==(const Vec4& other) const
 {
-	return Math::Equals(x, other.x) && Math::Equals(y, other.y) && Math::Equals(z, other.z) && Math::Equals(w, other.w);
+	return math::equals(x, other.x) && math::equals(y, other.y) && math::equals(z, other.z) && math::equals(w, other.w);
 }
 
 //-----------------------------------------------------------------------------
 inline bool Vec4::operator!=(const Vec4& other) const
 {
-	return !Math::Equals(x, other.x) || !Math::Equals(y, other.y) || !Math::Equals(z, other.z) || !Math::Equals(w, other.w);
+	return !math::equals(x, other.x) || !math::equals(y, other.y) || !math::equals(z, other.z) || !math::equals(w, other.w);
 }
 
 //-----------------------------------------------------------------------------
@@ -252,47 +253,47 @@ inline bool Vec4::operator>(const Vec4& other) const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec4::GetLength() const
+inline real Vec4::length() const
 {
-	return Math::Sqrt(x * x + y * y + z * z + w * w);
+	return math::sqrt(x * x + y * y + z * z + w * w);
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec4::GetSquaredLength() const
+inline real Vec4::squared_length() const
 {
 	return x * x + y * y + z * z + w * w;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::Normalize()
+inline Vec4& Vec4::normalize()
 {
-	real length = GetLength();
+	real len = length();
 
-	if (Math::Equals(length, (real)0.0))
+	if (math::equals(len, (real)0.0))
 	{
 		return *this;
 	}
 
-	length = (real)(1.0 / length);
+	len = (real)(1.0 / len);
 
-	x *= length;
-	y *= length;
-	z *= length;
-	w *= length;
+	x *= len;
+	y *= len;
+	z *= len;
+	w *= len;
 
 	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::GetNormalized() const
+inline Vec4 Vec4::get_normalized() const
 {
 	Vec4 tmp(x, y, z, w);
 
-	return tmp.Normalize();
+	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::Negate()
+inline Vec4& Vec4::negate()
 {
 	x = -x;
 	y = -y;
@@ -309,19 +310,19 @@ inline Vec4 Vec4::operator-() const
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec4::GetDistanceTo(const Vec4& a) const
+inline real Vec4::get_distance_to(const Vec4& a) const
 {
-	return (*this - a).GetLength();
+	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline real Vec4::GetAngleBetween(const Vec4& a) const
+inline real Vec4::get_angle_between(const Vec4& a) const
 {
-	return Math::Acos(this->Dot(a) / (this->GetLength() * a.GetLength()));
+	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec4::Zero()
+inline void Vec4::zero()
 {
 	x = 0.0;
 	y = 0.0;
@@ -330,19 +331,19 @@ inline void Vec4::Zero()
 }
 
 //-----------------------------------------------------------------------------
-inline real* Vec4::ToFloatPtr()
+inline real* Vec4::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const real* Vec4::ToFloatPtr() const
+inline const real* Vec4::to_float_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Str Vec4::ToStr() const
+inline Str Vec4::to_str() const
 {
 	Str tmp;