forked from vectozavr/pseudo3DEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint2D.h
50 lines (40 loc) · 1.46 KB
/
Point2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by Neirokan on 09.05.2020
//
#ifndef PSEUDO3DENGINE_POINT2D_H
#define PSEUDO3DENGINE_POINT2D_H
struct Point2D
{
double x;
double y;
Point2D();
Point2D(double x, double y);
Point2D operator+(const Point2D& point2D) const;
Point2D operator-(const Point2D& point2D) const;
Point2D operator*(double number) const;
Point2D operator/(double number) const;
Point2D& operator=(const Point2D& point2D);
Point2D& operator+=(const Point2D& point2D);
Point2D& operator-=(const Point2D& point2D);
Point2D& operator*=(double number);
Point2D& operator/=(double number);
bool operator==(const Point2D& point2D);
bool operator!=(const Point2D& point2D);
bool operator<(const Point2D& point2D) const;
// Returns dot product
double operator*(const Point2D& point2D) const;
// Returns cross product
[[nodiscard]] double cross(const Point2D& point2D) const;
// Returns dot product, but static
static double dot(const Point2D& a, const Point2D& b);
// Returns cross product, but static
static double cross(const Point2D& a, const Point2D& b);
// Returns normalized vector
[[nodiscard]] Point2D normalize() const;
// Returns squared vector length
double sqrAbs() const;
// Returns vector length
[[nodiscard]] double abs() const;
[[nodiscard]] double getAngle(const Point2D& b) const;
};
#endif //PSEUDO3DENGINE_POINT2D_H