summaryrefslogtreecommitdiffstats
path: root/src/math/point.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-04-28 22:56:07 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-04-28 22:56:07 +0200
commitb5b9fdb6803f5c5c70a39bd1abe65c6b651886a9 (patch)
treec8eb61f6cdcddd6aa08e2c63c505d5ca9e1798e1 /src/math/point.h
parent1c275dbd78c0c36905b921e889951762ef445e35 (diff)
downloadcolobot-b5b9fdb6803f5c5c70a39bd1abe65c6b651886a9.tar.gz
colobot-b5b9fdb6803f5c5c70a39bd1abe65c6b651886a9.tar.bz2
colobot-b5b9fdb6803f5c5c70a39bd1abe65c6b651886a9.zip
Structs continued
Diffstat (limited to 'src/math/point.h')
-rw-r--r--src/math/point.h47
1 files changed, 46 insertions, 1 deletions
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 <cmath>
+
+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
+*/
+
+};