Enmesh
Loading...
Searching...
No Matches
point.h
1#ifndef POINT_H
2#define POINT_H
3
4#include <iostream>
5#include <cmath>
6#include <vector>
7
8
9namespace Enmesh {
10
15struct Point {
16 float x, y, z;
17
18
23 Point() : x(0), y(0), z(0) {}
24
25
32 Point(float x_, float y_) : x(x_), y(y_), z(0) {}
33
34
42 Point(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
43
44
50 float length() const;
51
52
59 float distance(const Point& other) const;
60
61
62 // Operator overloads for vector arithmetic
63 Point operator-(const Point& other) const;
64 Point operator+(const Point& other) const;
65 Point operator*(float scalar) const;
66 Point operator/(float scalar) const;
67
68 bool operator==(const Point& other) const;
69 void operator+=(const Point& other);
70 void operator/=(float scalar);
71 void operator*=(float scalar);
72
73 float dot(const Point& other) const;
74 Point cross(const Point& other) const;
75
76
84 friend std::ostream& operator<<(std::ostream& os, const Point& point);
85};
86
87} // namespace Enmesh
88
89#endif
A struct representing a point in 3D space.
Definition point.h:15
friend std::ostream & operator<<(std::ostream &os, const Point &point)
Overload the << operator to print the point's coordinates.
Definition point.cpp:66
float z
Coordinates of the point.
Definition point.h:16
Point()
Construct a new Point object at the origin.
Definition point.h:23
float length() const
Calculate the length of the vector from the origin to this point.
Definition point.cpp:5
Point(float x_, float y_)
Construct a new Point object at the specified coordinates (z defaults to 0)
Definition point.h:32
float distance(const Point &other) const
Calculate the distance between this point and another point.
Definition point.cpp:10
Point(float x_, float y_, float z_)
Construct a new Point object at the specified coordinates.
Definition point.h:42