ProjGeom 1.0.11
Loading...
Searching...
No Matches
ck_plane.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <array>
8
9#include "pg_plane.hpp"
10
11#if __cpp_concepts >= 201907L
12# include "ck_concepts.hpp"
13#endif
14
15namespace fun {
23 template <class Line, class Point = typename Line::Dual>
24#if __cpp_concepts >= 201907L
25 requires CayleyKleinPlanePrimitiveDual<Line, Point>
26#endif
27 constexpr auto is_perpendicular(const Line& l_1, const Line& l_2) -> bool {
28 return l_1.perp().incident(l_2);
29 }
30
43 template <class Point, class Line>
44#if __cpp_concepts >= 201907L
45 requires CayleyKleinPlanePrimitiveDual<Point, Line>
46#endif
47 constexpr auto altitude(const Point& pt_p, const Line& ln_m) -> Line {
48 return ln_m.perp().meet(pt_p);
49 }
50
61 template <class Point, class Line = typename Point::Dual>
62#if __cpp_concepts >= 201907L
63 requires CayleyKleinPlanePrimitiveDual<Point, Line>
64#endif
65 constexpr auto orthocenter(const std::array<Point, 3>& triangle) -> Point {
66 const auto& [a_1, a_2, a_3] = triangle;
67 assert(!coincident(a_1, a_2, a_3));
68 const auto t1 = altitude(a_1, a_2.meet(a_3));
69 const auto t2 = altitude(a_2, a_3.meet(a_1));
70 return t1.meet(t2);
71 }
72
83 template <class Point, class Line>
84#if __cpp_concepts >= 201907L
85 requires CayleyKleinPlanePrimitiveDual<Point, Line>
86#endif
87 constexpr auto tri_altitude(const std::array<Point, 3>& triangle) -> std::array<Line, 3> {
88 const auto [l1, l2, l3] = tri_dual(triangle);
89 const auto& [a_1, a_2, a_3] = triangle;
90 assert(!coincident(a_1, a_2, a_3));
91 auto&& t1 = altitude(a_1, l1);
92 auto&& t2 = altitude(a_2, l2);
93 auto&& t3 = altitude(a_3, l3);
94 return {t1, t2, t3};
95 }
96
109 template <typename Value, class Point, class Line = typename Point::Dual>
110#if __cpp_concepts >= 201907L
111 requires CayleyKleinPlaneDual<Value, Point, Line>
112#endif
113 constexpr auto reflect(const Line& mirror, const Point& pt_p) -> Point {
114 return involution(mirror.perp(), mirror, pt_p);
115 }
116
117} // namespace fun
C++20 concepts for Cayley-Klein planes.
Definition ck_concepts.hpp:11
constexpr auto orthocenter(const std::array< Point, 3 > &triangle) -> Point
Compute the orthocenter of a triangle (Cayley-Klein).
Definition ck_plane.hpp:65
constexpr auto tri_altitude(const std::array< Point, 3 > &triangle) -> std::array< Line, 3 >
Compute all three altitudes of a triangle (Cayley-Klein).
Definition ck_plane.hpp:87
constexpr auto reflect(const Line &mirror, const Point &pt_p) -> Point
Reflect a point across a line (Cayley-Klein).
Definition ck_plane.hpp:113
constexpr auto tri_dual(const std::array< Point, 3 > &triangle) -> std::array< Line, 3 >
Dual of triangle.
Definition pg_plane.hpp:93
constexpr auto altitude(const Point &pt_p, const Line &ln_m) -> Line
Compute the altitude from a point to a line (Cayley-Klein).
Definition ck_plane.hpp:47
constexpr auto coincident(const Point &pt_p, const Point &pt_q, const Point &pt_r) -> bool
Coincident.
Definition pg_plane.hpp:51
constexpr auto is_perpendicular(const Line &l_1, const Line &l_2) -> bool
Check if two lines are perpendicular (Cayley-Klein).
Definition ck_plane.hpp:27
constexpr auto involution(const Point &origin, const Line &mirror, const Point &pt_p) -> Point
Involution on a point.
Definition pg_plane.hpp:210
Projective plane axioms and geometric checks (coincidence, Pappus, Desargues).