summaryrefslogtreecommitdiff
path: root/src/point.h
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2022-04-02 09:13:33 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2022-04-02 09:13:33 +0400
commit806a1e093eeac8b426b20717c14260c9cb896798 (patch)
tree7b6e1a01958269ce78b9716461a9fa4c05d3dc5e /src/point.h
parent15ccb946f43283bfc91d80ddf012d9ae2a0333ed (diff)
Removed CUDA files and changed build system to premakeremake
Diffstat (limited to 'src/point.h')
-rw-r--r--src/point.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/point.h b/src/point.h
new file mode 100644
index 0000000..36cfda9
--- /dev/null
+++ b/src/point.h
@@ -0,0 +1,87 @@
+//
+// Created by saintruler on 11.04.19.
+//
+
+#ifndef OPENGLTEST_POINT_H
+#define OPENGLTEST_POINT_H
+
+#include <cmath>
+
+class point
+{
+public:
+ point(double x, double y)
+ {
+ this->x = x;
+ this->y = y;
+ }
+
+ friend point operator+(const point& left, const point& right)
+ {
+ return point(left.x + right.x, left.y + right.y);
+ }
+
+ friend point operator+=(point& left, const point& right)
+ {
+ left.x += right.x;
+ left.y += right.y;
+ return left;
+ }
+
+ friend point operator-(const point& left, const point& right)
+ {
+ return point(left.x - right.x, left.y - right.y);
+ }
+
+ friend point operator-=(point& left, const double right)
+ {
+ left.x -= right;
+ left.y -= right;
+ return left;
+ }
+
+ friend point operator/(const point& left, const double right)
+ {
+ return point(left.x / right, left.y / right);
+ }
+
+ friend point operator/=(point& left, const double right)
+ {
+ left.x /= right;
+ left.y /= right;
+ return left;
+ }
+
+ friend point operator*(const point& left, const double right)
+ {
+ return point(left.x * right, left.y * right);
+ }
+
+ friend point operator*=(point& left, const double right)
+ {
+ left.x *= right;
+ left.y *= right;
+ return left;
+ }
+
+ double length()
+ {
+ return sqrt(pow(x, 2) + pow(y, 2));
+ }
+
+ double length_sqared()
+ {
+ return pow(x, 2) + pow(y, 2);
+ }
+
+ void normalize()
+ {
+ const double l = length();
+ this->x /= l;
+ this->y /= l;
+ }
+
+ double x, y;
+};
+
+#endif //OPENGLTEST_POINT_H