1 #ifndef PSIM_GEOMETRY_H
2 #define PSIM_GEOMETRY_H
15 constexpr
Vector2D(
double x_coord,
double y_coord) noexcept
24 constexpr
Point(
double x_coord,
double y_coord) noexcept
54 [[nodiscard]]
bool overlaps(
const Line& other)
const noexcept;
55 [[nodiscard]]
bool contains(
const Line& other)
const noexcept;
56 [[nodiscard]]
bool contains(
const Point& point)
const noexcept;
67 bool operator==(const
Line& rhs)
const {
68 return p1 == rhs.p1 &&
p2 == rhs.p2;
82 [[nodiscard]] std::array<Line, 3>
lines() const noexcept;
84 [[nodiscard]]
double area() const noexcept;
93 bool operator==(const
Triangle& rhs) const;
95 std::ostream& operator<<(std::ostream& os, const
Triangle& triangle);
101 [[nodiscard]]
const char*
what() const noexcept
override {
102 return message_.c_str();
111 std::string message_;
Definition: geometry.h:114
Definition: geometry.h:99
void setMessage(std::string_view message)
Definition: geometry.h:106
const char * what() const noexcept override
Definition: geometry.h:101
Definition: geometry.h:122
Definition: geometry.h:13
std::ostream & operator<<(std::ostream &os, const Point &point)
Definition: geometry.cpp:30
std::pair< Point, Point > PointPair
Definition: geometry.h:37
Point operator-(const Point &lhs, const Point &rhs)
Definition: geometry.cpp:35
Definition: geometry.h:39
bool overlaps(const Line &other) const noexcept
Definition: geometry.cpp:58
PointPair getPoints() const noexcept
Definition: geometry.h:50
Point getRandPoint(double r1) const noexcept
Definition: geometry.cpp:142
bool contains(const Line &other) const noexcept
Definition: geometry.cpp:77
double intercept
Definition: geometry.h:46
Point p2
Definition: geometry.h:42
Point p1
Definition: geometry.h:41
PointPair boundingBox
Definition: geometry.h:47
double slope
Definition: geometry.h:45
bool operator>(const Line &rhs) const
Definition: geometry.h:70
bool intersects(const Line &other) const noexcept
Definition: geometry.cpp:94
Vector2D normal(int norm_sign=1) const noexcept
Definition: geometry.cpp:99
Line(Point pt1, Point pt2)
Definition: geometry.cpp:47
double length
Definition: geometry.h:48
std::optional< Point > getIntersection(const Line &other) const noexcept
Definition: geometry.cpp:106
Definition: geometry.h:23
double y
Definition: geometry.h:29
bool operator==(const Point &rhs) const
Definition: geometry.cpp:39
bool operator!=(const Point &rhs) const
Definition: geometry.cpp:43
constexpr Point(double x_coord, double y_coord) noexcept
Definition: geometry.h:24
double x
Definition: geometry.h:28
Definition: geometry.h:76
Point p3
Definition: geometry.h:80
bool intersects(const Triangle &other) const noexcept
Definition: geometry.cpp:170
std::array< Line, 3 > lines() const noexcept
Definition: geometry.cpp:163
Triangle(Point pt1, Point pt2, Point pt3)
Definition: geometry.cpp:153
Point getRandPoint(double r1, double r2) const noexcept
Definition: geometry.cpp:237
double area() const noexcept
Definition: geometry.cpp:253
bool contains(const Triangle &other) const noexcept
Definition: geometry.cpp:265
bool isClockwise() const noexcept
Definition: geometry.cpp:220
Point p1
Definition: geometry.h:78
Point p2
Definition: geometry.h:79
Definition: geometry.h:14
double y
Definition: geometry.h:20
constexpr Vector2D(double x_coord, double y_coord) noexcept
Definition: geometry.h:15
double x
Definition: geometry.h:19