From b5b9fdb6803f5c5c70a39bd1abe65c6b651886a9 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 28 Apr 2012 22:56:07 +0200 Subject: Structs continued --- src/math/point.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'src/math/point.h') diff --git a/src/math/point.h b/src/math/point.h index 3d42540..f28411e 100644 --- a/src/math/point.h +++ b/src/math/point.h @@ -20,6 +20,49 @@ #pragma once +#include + +namespace Math +{ + +/** 2D Point + + Represents a 2D point (x, y). + Contains the required methods for operating on points. + + All methods are made inline to maximize optimization. + + TODO test + + */ +struct Point +{ + //! X coord + float x; + //! Y coord + float y; + + inline Point() + { + LoadZero(); + } + + inline Point(float x, float y) + { + this->x = x; + this->y = y; + } + + inline void LoadZero() + { + x = y = 0.0f; + } + + inline float Length() + { + return std::sqrt(x*x + y*y); + } +}; /* TODO FPOINT RotatePoint(FPOINT center, float angle, FPOINT p); FPOINT RotatePoint(float angle, FPOINT p); @@ -36,4 +79,6 @@ BOOL IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p); BOOL LineFunction(FPOINT p1, FPOINT p2, float &a, float &b); -*/ \ No newline at end of file +*/ + +}; -- cgit v1.2.3-1-g7c22