瀏覽代碼

Port Vector2 to NMF

Daniele Bartolini 12 年之前
父節點
當前提交
8fd5d7a93b

+ 2 - 2
engine/CMakeLists.txt

@@ -150,7 +150,6 @@ set (MATH_SRC
 	core/math/Matrix4x4.cpp
 	core/math/Plane.cpp
 	core/math/Quaternion.cpp
-	core/math/Vector2.cpp
 	core/math/Vector3.cpp
 	core/math/Vector4.cpp
 )
@@ -158,9 +157,10 @@ set (MATH_SRC
 set (MATH_HEADERS
 	core/math/Color4.h
 	core/math/Intersection.h
+	core/math/MathTypes.h
+	core/math/MathUtils.h
 	core/math/Matrix3x3.h
 	core/math/Matrix4x4.h
-	core/math/MathUtils.h
 	core/math/Plane.h
 	core/math/Quaternion.h
 	core/math/Random.h

+ 2 - 2
engine/core/bv/Rect.cpp

@@ -90,7 +90,7 @@ Vector2 Rect::vertex(uint32_t index) const
 			return Vector2(m_min.x, m_max.y);
 	}
 
-	return Vector2::ZERO;
+	return vector2::ZERO;
 }
 
 //-----------------------------------------------------------------------------
@@ -102,7 +102,7 @@ Vector2 Rect::center() const
 //-----------------------------------------------------------------------------
 float Rect::radius() const
 {
-	return (m_max - (m_min + m_max) * 0.5).length();
+	return vector2::length((m_max - (m_min + m_max) * 0.5));
 }
 
 //-----------------------------------------------------------------------------

+ 7 - 7
engine/core/math/Intersection.h

@@ -656,7 +656,7 @@ inline bool Intersection::test_frustum_box(const Frustum& f, const Box& b)
 inline bool Intersection::test_circle_circle(const Circle& c1, const Circle& c2, Vector2& penetration)
 {
 	Vector2 distance = c1.center() - c2.center();
-	float distanceLen2 = distance.squared_length();
+	float distanceLen2 = vector2::squared_length(distance);
 	float radiusSum = c1.radius() + c2.radius();
 	if (distanceLen2 > radiusSum*radiusSum)
 	{
@@ -681,7 +681,7 @@ inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vec
 	// c1 == static circle
 	// c2 == moving circle
 	Vector2 d = d2 - d1;
-	d.normalize();
+	vector2::normalize(d);
 
 	const Vector2& cs = c1.center();
 	const Vector2& cm = c2.center();
@@ -690,15 +690,15 @@ inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vec
 	float r = c1.radius() + c2.radius();
 
 	// If ||e|| < r, int32_tersection occurs at t = 0
-	if (e.length() < r)
+	if (vector2::length(e) < r)
 	{
 		it = 0.0;
 		return true;
 	}
 
 	// it == Intersection Time
-	float ed = e.dot(d);
-	float squared = (ed * ed) + (r * r) - e.dot(e);
+	float ed = vector2::dot(e, d);
+	float squared = (ed * ed) + (r * r) - vector2::dot(e, e);
 
 	// If the value inside the square root is neg, then no int32_tersection
 	if (squared < 0.0)
@@ -707,7 +707,7 @@ inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vec
 	}
 
 	float t = ed - math::sqrt(squared);
-	float l = (d2 - d1).length();
+	float l = vector2::length(d2 - d1);
 
 	// If t < 0 || t > l, then non int32_tersection in the considered period of time
 	if (t < 0.0 || t > l)
@@ -829,7 +829,7 @@ inline bool Intersection::test_circle_rect(const Circle& c1, const Rect& r2, Vec
 	else
 	{
 		penetration += Vector2(c1.radius(), c1.radius());
-		float len = math::sqrt(penetration.squared_length());
+		float len = math::sqrt(vector2::squared_length(penetration));
 		if (len > c1.radius())
 		{
 			return false;

+ 19 - 6
engine/core/math/Vector2.cpp → engine/core/math/MathTypes.h

@@ -24,15 +24,28 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vector2.h"
+#pragma once
 
 namespace crown
 {
 
-const Vector2 Vector2::ZERO	= Vector2(0.0, 0.0);
-const Vector2 Vector2::ONE	= Vector2(1.0, 1.0);
-const Vector2 Vector2::XAXIS	= Vector2(1.0, 0.0);
-const Vector2 Vector2::YAXIS	= Vector2(0.0, 1.0);
+struct Vector2
+{
+	Vector2();
+	Vector2(float val);
+	Vector2(float nx, float ny);
+	Vector2(const float v[2]);
+	Vector2(const Vector2& a);
 
-} // namespace crown
+	float operator[](uint32_t i) const;
+	float& operator[](uint32_t i);
+
+	Vector2& operator+=(const Vector2& a);
+	Vector2& operator-=(const Vector2& a);
+	Vector2& operator*=(float k);
+	Vector2& operator/=(float k);
 
+	float x, y;
+};
+
+} // namespace crown

+ 130 - 247
engine/core/math/Vector2.h

@@ -29,367 +29,250 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
+#include "MathTypes.h"
 
 namespace crown
 {
 
-/// 2D column vector.
-struct Vector2
-{
-public:
-
-	float				x, y;
-
-	/// Does nothing for efficiency.
-						Vector2();		
-
-	/// Initializes all the components to val							
-						Vector2(float val);	
-
-	/// Constructs from two components						
-						Vector2(float nx, float ny);
-
-	/// Constructs from array
-						Vector2(const float v[2]);
-						Vector2(const Vector2& a);					
+/// Negates @a a and returns the result.	
+Vector2 operator-(const Vector2& a);
 
-	/// Random access by index
-	float				operator[](uint32_t i) const;
+/// Adds the vector @a to @b and returns the result.
+Vector2 operator+(Vector2 a, const Vector2& b);
 
-	/// Random access by index			
-	float&				operator[](uint32_t i);					
+/// Subtracts the vector @a b from @a a and returns the result.
+Vector2 operator-(Vector2 a, const Vector2& b);
 
-	Vector2				operator+(const Vector2& a) const;			
-	Vector2&			operator+=(const Vector2& a);				
-	Vector2 			operator-(const Vector2& a) const;			
-	Vector2&			operator-=(const Vector2& a);				
-	Vector2				operator*(float k) const;				
-	Vector2&			operator*=(float k);						
-	Vector2				operator/(float k) const;				
-	Vector2&			operator/=(float k);
+/// Multiplies the vector @a a by the scalar @a k and returns the result.
+Vector2 operator*(Vector2 a, float k);
 
-	/// Dot product						
-	float				dot(const Vector2& a) const;				
+/// @copydoc operator*(Vector2, float)
+Vector2 operator*(float k, Vector2 a);
 
-	/// For simmetry
-	friend Vector2		operator*(float k, const Vector2& a);		
+/// Divides the vector @a a by the scalar @a k and returns the result.
+Vector2 operator/(Vector2 a, float k);
 
-	bool				operator==(const Vector2& other) const;	
-	bool				operator!=(const Vector2& other) const;
+/// Returns true whether the vectors @a a and @a b are equal.
+bool operator==(const Vector2& a, const Vector2& b);
 
-	/// Returns whether all the components of this vector are smaller than all of the @a other vector	
-	bool				operator<(const Vector2& other) const;		
+namespace vector2
+{
+	const Vector2 ZERO = Vector2(0, 0);
 
-	/// Returns whether all the components of this vector are greater than all of the @a other vector
-	bool				operator>(const Vector2& other) const;		
+	/// Dot product
+	float dot(const Vector2& a, const Vector2& b);
 
 	/// Returns the vector's length
-	float				length() const;
+	float length(const Vector2& a);
 
 	/// Returns the vector's squared length							
-	float				squared_length() const;
+	float squared_length(const Vector2& a);
 
 	/// Sets the vector's length					
-	void				set_length(float len);					
-	float				get_angle() const;
-	float				get_angle_2d() const;
+	void set_length(Vector2& a, float len);
 
 	/// Normalizes the vector
-	Vector2&			normalize();
-
-	/// Returns the normalized vector							
-	Vector2				get_normalized() const;
-
-	/// Negates the vector (i.e. builds the inverse)					
-	Vector2&			negate();
-
-	/// Negates the vector (i.e. builds the inverse)								
-	Vector2				operator-() const;						
+	Vector2 normalize(Vector2& a);
 
 	/// Returns the distance
-	float				get_distance_to(const Vector2& a) const;
-
-	/// Returns the angle in radian	
-	float				get_angle_between(const Vector2& a) const;
+	float distance(const Vector2& a, const Vector2& b);
 
-	/// Sets all components to zero
-	void				zero();
+	/// Returns the angle between
+	float angle(const Vector2& a, const Vector2& b);
 
 	/// Returns the pointer to the vector's data
-	float*				to_float_ptr();	
+	float* to_float_ptr(Vector2& a);
 
-	/// Returns the pointer to the vector's data						
-	const float*		to_float_ptr() const;					
-
-	static const Vector2	ZERO;
-	static const Vector2	ONE;
-	static const Vector2	XAXIS;
-	static const Vector2	YAXIS;
-};
+	/// Returns the pointer to the vector's data
+	const float* to_float_ptr(const Vector2& a);
+} // namespace vector2
 
-//-----------------------------------------------------------------------------
-inline Vector2::Vector2()
+inline Vector2 operator-(const Vector2& a)
 {
+	return Vector2(-a.x, -a.y);
 }
 
-//-----------------------------------------------------------------------------
-inline Vector2::Vector2(float val) : x(val), y(val)
+inline Vector2 operator+(Vector2 a, const Vector2& b)
 {
+	a += b;
+	return a;
 }
 
-//-----------------------------------------------------------------------------
-inline Vector2::Vector2(float nx, float ny) : x(nx), y(ny)
+inline Vector2 operator-(Vector2 a, const Vector2& b)
 {
+	a -= b;
+	return a;
 }
 
-//-----------------------------------------------------------------------------
-inline Vector2::Vector2(const float a[2]) : x(a[0]), y(a[1])
+inline Vector2 operator*(Vector2 a, float k)
 {
+	a *= k;
+	return a;
 }
 
-//-----------------------------------------------------------------------------
-inline Vector2::Vector2(const Vector2& a) : x(a.x), y(a.y)
+inline Vector2 operator*(float k, Vector2 a)
 {
+	a *= k;
+	return a;
 }
 
-//-----------------------------------------------------------------------------
-inline float Vector2::operator[](uint32_t i) const
+inline Vector2 operator/(Vector2 a, float k)
 {
-	CE_ASSERT(i < 2, "Index must be < 2");
-
-	return (&x)[i];
+	a /= k;
+	return a;
 }
 
-//-----------------------------------------------------------------------------
-inline float& Vector2::operator[](uint32_t i)
+inline bool operator==(const Vector2& a, const Vector2& b)
 {
-	CE_ASSERT(i < 2, "Index must be < 2");
-
-	return (&x)[i];
+	return math::equals(a.x, b.x) && math::equals(a.y, b.y);
 }
 
-//-----------------------------------------------------------------------------
-inline Vector2 Vector2::operator+(const Vector2& a) const
-{
-	return Vector2(x + a.x, y + a.y);
-}
-
-//-----------------------------------------------------------------------------
-inline Vector2& Vector2::operator+=(const Vector2& a)
+namespace vector2
 {
-	x += a.x;
-	y += a.y;
 
-	return *this;
-}
-
-//-----------------------------------------------------------------------------
-inline Vector2 Vector2::operator-(const Vector2& a) const
-{
-	return Vector2(x - a.x, y - a.y);
-}
-
-//-----------------------------------------------------------------------------
-inline Vector2& Vector2::operator-=(const Vector2& a)
-{
-	x -= a.x;
-	y -= a.y;
-
-	return *this;
-}
-
-//-----------------------------------------------------------------------------
-inline Vector2 Vector2::operator*(float k) const
-{
-	return Vector2(x * k, y * k);
-}
+	//-----------------------------------------------------------------------------
+	inline float dot(const Vector2& a, const Vector2& b)
+	{
+		return a.x * b.x + a.y * b.y;
+	}
 
-//-----------------------------------------------------------------------------
-inline Vector2& Vector2::operator*=(float k)
-{
-	x *= k;
-	y *= k;
+	//-----------------------------------------------------------------------------
+	inline float length(const Vector2& a)
+	{
+		return math::sqrt(a.x * a.x + a.y * a.y);
+	}
 
-	return *this;
-}
+	//-----------------------------------------------------------------------------
+	inline float squared_length(const Vector2& a)
+	{
+		return a.x * a.x + a.y * a.y;
+	}
 
-//-----------------------------------------------------------------------------
-inline Vector2 Vector2::operator/(float k) const
-{
-	CE_ASSERT(k != (float)0.0, "Division by zero");
+	//-----------------------------------------------------------------------------
+	inline void set_length(Vector2& a, float len)
+	{
+		normalize(a);
 
-	float inv = (float)(1.0 / k);
+		a.x *= len;
+		a.y *= len;
+	}
 
-	return Vector2(x * inv, y * inv);
-}
+	//-----------------------------------------------------------------------------
+	inline Vector2 normalize(Vector2& a)
+	{
+		float inv_len = 1.0 / length(a);
 
-//-----------------------------------------------------------------------------
-inline Vector2& Vector2::operator/=(float k)
-{
-	CE_ASSERT(k != (float)0.0, "Division by zero");
+		a.x *= inv_len;
+		a.y *= inv_len;
 
-	float inv = (float)(1.0 / k);
+		return a;
+	}
 
-	x *= inv;
-	y *= inv;
+	//-----------------------------------------------------------------------------
+	inline float distance(const Vector2& a, const Vector2& b)
+	{
+		return length(b - a);
+	}
 
-	return *this;
-}
+	//-----------------------------------------------------------------------------
+	inline float angle(const Vector2& a, const Vector2& b)
+	{
+		return math::acos(dot(a, b) / (length(a) * length(b)));
+	}
 
-//-----------------------------------------------------------------------------
-inline float Vector2::dot(const Vector2& a) const
-{
-	return x * a.x + y * a.y;
-}
+	//-----------------------------------------------------------------------------
+	inline float* to_float_ptr(Vector2& a)
+	{
+		return &a.x;
+	}
 
-//-----------------------------------------------------------------------------
-inline bool Vector2::operator==(const Vector2& other) const
-{
-	return math::equals(x, other.x) && math::equals(y, other.y);
-}
+	//-----------------------------------------------------------------------------
+	inline const float* to_float_ptr(const Vector2& a)
+	{
+		return &a.x;
+	}
+} // namespace vector2
 
 //-----------------------------------------------------------------------------
-inline bool Vector2::operator!=(const Vector2& other) const
+inline Vector2::Vector2()
 {
-	return !math::equals(x, other.x) || !math::equals(y, other.y);
+	// Do not initialize
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vector2::operator<(const Vector2& other) const
+inline Vector2::Vector2(float val) : x(val), y(val)
 {
-	return ((x < other.x) && (y < other.y));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vector2::operator>(const Vector2& other) const
+inline Vector2::Vector2(float nx, float ny) : x(nx), y(ny)
 {
-	return ((x > other.x) && (y > other.y));
 }
 
 //-----------------------------------------------------------------------------
-inline float Vector2::length() const
+inline Vector2::Vector2(const float a[2]) : x(a[0]), y(a[1])
 {
-	return math::sqrt(x * x + y * y);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vector2::squared_length() const
+inline Vector2::Vector2(const Vector2& a) : x(a.x), y(a.y)
 {
-	return x * x + y * y;
 }
 
 //-----------------------------------------------------------------------------
-inline void Vector2::set_length(float len)
+inline float Vector2::operator[](uint32_t i) const
 {
-	normalize();
+	CE_ASSERT(i < 2, "Index must be < 2");
 
-	x *= len;
-	y *= len;
+	return (&x)[i];
 }
 
 //-----------------------------------------------------------------------------
-inline float Vector2::get_angle() const
+inline float& Vector2::operator[](uint32_t i)
 {
-	return math::atan2(y, x);
-}
+	CE_ASSERT(i < 2, "Index must be < 2");
 
-//-----------------------------------------------------------------------------
-inline float Vector2::get_angle_2d() const
-{
-	return math::atan2(-y, x);
+	return (&x)[i];
 }
 
 //-----------------------------------------------------------------------------
-inline Vector2& Vector2::normalize()
+inline Vector2& Vector2::operator+=(const Vector2& a)
 {
-	float len = length();
-
-	if (math::equals(len, (float)0.0))
-	{
-		return *this;
-	}
-
-	x /= len;
-	y /= len;
+	x += a.x;
+	y += a.y;
 
 	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vector2 Vector2::get_normalized() const
-{
-	Vector2 tmp(x, y);
-
-	return tmp.normalize();
-}
-
-//-----------------------------------------------------------------------------
-inline Vector2& Vector2::negate()
+inline Vector2& Vector2::operator-=(const Vector2& a)
 {
-	x = -x;
-	y = -y;
+	x -= a.x;
+	y -= a.y;
 
 	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vector2 Vector2::operator-() const
-{
-	return Vector2(-x, -y);
-}
-
-//-----------------------------------------------------------------------------
-inline float Vector2::get_distance_to(const Vector2& a) const
-{
-	return (*this - a).length();
-}
-
-//-----------------------------------------------------------------------------
-inline float Vector2::get_angle_between(const Vector2& a) const
-{
-	return math::acos(this->dot(a) / (this->length() * a.length()));
-}
-
-//-----------------------------------------------------------------------------
-inline void Vector2::zero()
-{
-	x = 0.0;
-	y = 0.0;
-}
-
-//-----------------------------------------------------------------------------
-inline float* Vector2::to_float_ptr()
+inline Vector2& Vector2::operator*=(float k)
 {
-	return &x;
-}
+	x *= k;
+	y *= k;
 
-//-----------------------------------------------------------------------------
-inline const float* Vector2::to_float_ptr() const
-{
-	return &x;
+	return *this;
 }
 
 //-----------------------------------------------------------------------------
-inline Vector2 get_projected_parallel(const Vector2& v, const Vector2& n)
+inline Vector2& Vector2::operator/=(float k)
 {
-	float n_len_q;
-	n_len_q = n.length();
-	n_len_q = n_len_q * n_len_q;
+	CE_ASSERT(k != (float)0.0, "Division by zero");
 
-	return n * (v.dot(n) / n_len_q);
-}
+	float inv = (float)(1.0 / k);
 
-//-----------------------------------------------------------------------------
-inline Vector2 get_projected_perpendicular(const Vector2& v, const Vector2& n)
-{
-	return v - get_projected_parallel(v, n);
-}
+	x *= inv;
+	y *= inv;
 
-//-----------------------------------------------------------------------------
-inline Vector2 operator*(float k, const Vector2& a)
-{
-	return a * k;
+	return *this;
 }
 
 } // namespace crown
-

+ 1 - 1
engine/input/Touch.h

@@ -80,7 +80,7 @@ public:
 	/// to right and +Y extends from top to bottom.
 	Vector2 pointer_xy(uint8_t p)
 	{
-		if (p >= MAX_POINTER_IDS) return Vector2::ZERO;
+		if (p >= MAX_POINTER_IDS) return vector2::ZERO;
 		return Vector2(m_x[p], m_y[p]);
 	}
 

+ 2 - 2
engine/lua/LuaSystem.cpp

@@ -51,7 +51,7 @@ extern int vector3_subtract(lua_State* L);
 extern int vector3_multiply(lua_State* L);
 extern int vector3_divide(lua_State* L);
 extern int vector3_negate(lua_State* L);
-extern int vector2(lua_State* L);
+extern int vector2_new(lua_State* L);
 extern int vector3(lua_State* L);
 extern int matrix4x4(lua_State* L);
 extern int quaternion(lua_State* L);
@@ -60,7 +60,7 @@ extern int quaternion(lua_State* L);
 static int crown_lua_vector2_call(lua_State* L)
 {
 	lua_remove(L, 1);
-	return vector2(L);
+	return vector2_new(L);
 }
 
 //-----------------------------------------------------------------------------

+ 14 - 55
engine/lua/LuaVector2.cpp

@@ -32,7 +32,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vector2(lua_State* L)
+CE_EXPORT int vector2_new(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -163,7 +163,7 @@ CE_EXPORT int vector2_dot(lua_State* L)
 	Vector2& a = stack.get_vector2(1);
 	Vector2& b = stack.get_vector2(2);
 
-	stack.push_float(a.dot(b));
+	stack.push_float(vector2::dot(a, b));
 
 	return 1;
 }
@@ -181,32 +181,6 @@ CE_EXPORT int vector2_equal(lua_State* L)
 	return 1;
 }
 
-//-----------------------------------------------------------------------------
-CE_EXPORT int vector2_lower(lua_State* L)
-{
-	LuaStack stack(L);
-	
-	Vector2& a = stack.get_vector2(1);
-	Vector2& b = stack.get_vector2(2);
-
-	stack.push_bool(a < b);
-
-	return 1;
-}
-
-//-----------------------------------------------------------------------------
-CE_EXPORT int vector2_greater(lua_State* L)
-{
-	LuaStack stack(L);
-	
-	Vector2& a = stack.get_vector2(1);
-	Vector2& b = stack.get_vector2(2);
-	
-	stack.push_bool(a > b);
-
-	return 1;
-}
-
 //-----------------------------------------------------------------------------
 CE_EXPORT int vector2_length(lua_State* L)
 {
@@ -214,7 +188,7 @@ CE_EXPORT int vector2_length(lua_State* L)
 
 	Vector2& a = stack.get_vector2(1);
 
-	stack.push_float(a.length());
+	stack.push_float(vector2::length(a));
 
 	return 1;
 }
@@ -226,7 +200,7 @@ CE_EXPORT int vector2_squared_length(lua_State* L)
 
 	Vector2& a = stack.get_vector2(1);
 
-	stack.push_float(a.squared_length());
+	stack.push_float(vector2::squared_length(a));
 
 	return 1;
 }
@@ -239,7 +213,7 @@ CE_EXPORT int vector2_set_length(lua_State* L)
 	Vector2& a = stack.get_vector2(1);
 	float len = stack.get_float(2);
 
-	a.set_length(len);
+	vector2::set_length(a, len);
 
 	return 0;
 }
@@ -251,7 +225,7 @@ CE_EXPORT int vector2_normalize(lua_State* L)
 
 	Vector2& a = stack.get_vector2(1);
 
-	stack.push_vector2(a.normalize());
+	stack.push_vector2(vector2::normalize(a));
 
 	return 1;
 }
@@ -269,47 +243,35 @@ CE_EXPORT int vector2_negate(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vector2_get_distance_to(lua_State* L)
+CE_EXPORT int vector2_distance(lua_State* L)
 {
 	LuaStack stack(L);
 	
 	Vector2& a = stack.get_vector2(1);
 	Vector2& b = stack.get_vector2(2);
 
-	stack.push_float(a.get_distance_to(b));
+	stack.push_float(vector2::distance(a, b));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vector2_get_angle_between(lua_State* L)
+CE_EXPORT int vector2_angle(lua_State* L)
 {
 	LuaStack stack(L);
 	
 	Vector2& a = stack.get_vector2(1);
 	Vector2& b = stack.get_vector2(2);
 
-	stack.push_float(a.get_angle_between(b));
+	stack.push_float(vector2::angle(a, b));
 
 	return 1;
 }
 
-//-----------------------------------------------------------------------------
-CE_EXPORT int vector2_zero(lua_State* L)
-{
-	LuaStack stack(L);
-
-	Vector2& a = stack.get_vector2(1);
-
-	a.zero();
-
-	return 0;
-}
-
 //-----------------------------------------------------------------------------
 void load_vector2(LuaEnvironment& env)
 {
-	env.load_module_function("Vector2", "new",					vector2);
+	env.load_module_function("Vector2", "new",					vector2_new);
 	env.load_module_function("Vector2", "x", 					vector2_x);
 	env.load_module_function("Vector2", "y", 					vector2_y);
 	env.load_module_function("Vector2", "set_x", 				vector2_set_x);
@@ -321,16 +283,13 @@ void load_vector2(LuaEnvironment& env)
 	env.load_module_function("Vector2", "divide",				vector2_divide);
 	env.load_module_function("Vector2", "dot",					vector2_dot);
 	env.load_module_function("Vector2", "equal",				vector2_equal);
-	env.load_module_function("Vector2", "lower",				vector2_lower);
-	env.load_module_function("Vector2", "greater",				vector2_greater);
 	env.load_module_function("Vector2", "length",				vector2_length);
 	env.load_module_function("Vector2", "squared_length",		vector2_squared_length);
 	env.load_module_function("Vector2", "set_length",			vector2_set_length);
 	env.load_module_function("Vector2", "normalize",			vector2_normalize);
 	env.load_module_function("Vector2", "negate",				vector2_negate);
-	env.load_module_function("Vector2", "get_distance_to",		vector2_get_distance_to);
-	env.load_module_function("Vector2", "get_angle_between",	vector2_get_angle_between);
-	env.load_module_function("Vector2", "zero",					vector2_zero);
+	env.load_module_function("Vector2", "distance",				vector2_distance);
+	env.load_module_function("Vector2", "angle",				vector2_angle);
 }
 
-} // namespace crown
+} // namespace crown