ProjGeom 1.0.11
Loading...
Searching...
No Matches
pg_plane.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <array>
8#include <cassert>
9
10#if __cpp_concepts >= 201907L
11# include "pg_concepts.hpp"
12#endif
13
14namespace fun {
24 template <class Point, class Line>
25#if __cpp_concepts >= 201907L
26 requires ProjPlanePrimDual<Point, Line>
27#endif
28 inline auto check_axiom(const Point& pt_p, const Point& pt_q, const Line& ln_l) -> bool {
29 if (pt_p != pt_p) return false;
30 if (pt_p.incident(ln_l) != ln_l.incident(pt_p)) return false;
31 if (pt_p.meet(pt_q) != pt_q.meet(pt_p)) return false;
32 const auto ln_m = pt_p.meet(pt_q);
33 if (!(ln_m.incident(pt_p) && ln_m.incident(pt_q))) return false;
34 return true;
35 }
36
47 template <class Point, class Line = typename Point::Dual>
48#if __cpp_concepts >= 201907L
49 requires ProjPlanePrimDual<Point, Line>
50#endif
51 constexpr auto coincident(const Point& pt_p, const Point& pt_q, const Point& pt_r) -> bool {
52 return pt_p.meet(pt_q).incident(pt_r);
53 }
54
64 template <class Point, class Line = typename Point::Dual>
65#if __cpp_concepts >= 201907L
66 requires ProjPlanePrimDual<Point, Line>
67#endif
68 constexpr auto check_pappus(const std::array<Point, 3>& coline1,
69 const std::array<Point, 3>& coline2) -> bool {
70 const auto& [pt_a, pt_b, pt_c] = coline1;
71 const auto& [pt_d, pt_e, pt_f] = coline2;
72 const auto pt_g = (pt_a.meet(pt_e)).meet(pt_b.meet(pt_d));
73 const auto pt_h = (pt_a.meet(pt_f)).meet(pt_c.meet(pt_d));
74 const auto pt_i = (pt_b.meet(pt_f)).meet(pt_c.meet(pt_e));
75 return coincident(pt_g, pt_h, pt_i);
76 }
77
89 template <class Point, class Line = typename Point::Dual>
90#if __cpp_concepts >= 201907L
91 requires ProjPlanePrimDual<Point, Line>
92#endif
93 constexpr auto tri_dual(const std::array<Point, 3>& triangle) -> std::array<Line, 3> {
94 const auto& [a_1, a_2, a_3] = triangle;
95 assert(!coincident(a_1, a_2, a_3));
96 return {a_2.meet(a_3), a_1.meet(a_3), a_1.meet(a_2)};
97 }
98
108 template <class Point, class Line = typename Point::Dual>
109#if __cpp_concepts >= 201907L
110 requires ProjPlanePrimDual<Point, Line>
111#endif
112 constexpr auto persp(const std::array<Point, 3>& tri1, const std::array<Point, 3>& tri2)
113 -> bool {
114 const auto& [pt_a, pt_b, pt_c] = tri1;
115 const auto& [pt_d, pt_e, pt_f] = tri2;
116 const auto& o = pt_a.meet(pt_d).meet(pt_b.meet(pt_e));
117 return pt_c.meet(pt_f).incident(o);
118 }
119
129 template <class Point, class Line = typename Point::Dual>
130#if __cpp_concepts >= 201907L
131 requires ProjPlanePrimDual<Point, Line>
132#endif
133 constexpr auto check_desargue(const std::array<Point, 3>& tri1,
134 const std::array<Point, 3>& tri2) -> bool {
135 const auto trid1 = tri_dual(tri1);
136 const auto trid2 = tri_dual(tri2);
137 const auto bool1 = persp(tri1, tri2);
138 const auto bool2 = persp(trid1, trid2);
139 return (bool1 && bool2) || (!bool1 && !bool2);
140 }
141
154 template <typename Value, class Point, class Line>
155#if __cpp_concepts >= 201907L
156 requires ProjectivePlaneDual<Value, Point, Line>
157#endif
158 inline auto check_axiom2(const Point& pt_p, const Point& pt_q, const Line& ln_l, const Value& a,
159 const Value& b) -> bool {
160 if (pt_p.dot(ln_l) != ln_l.dot(pt_p)) return false;
161 if (pt_p.aux().incident(pt_p)) return false;
162 const auto ln_m = pt_p.meet(pt_q);
163 if (!ln_m.incident(Point::parametrize(a, pt_p, b, pt_q))) return false;
164 return true;
165 }
166
180 template <typename Value, class Point, class Line = typename Point::Dual>
181#if __cpp_concepts >= 201907L
182 requires ProjectivePlaneDual<Value, Point, Line>
183#endif
184 constexpr auto harm_conj(const Point& pt_a, const Point& pt_b, const Point& pt_c) -> Point {
185 assert(coincident(pt_a, pt_b, pt_c));
186 const auto ab = pt_a.meet(pt_b);
187 const auto lc = ab.aux().meet(pt_c);
188 return Point::parametrize(lc.dot(pt_a), pt_a, lc.dot(pt_b), pt_b);
189 }
190
206 template <typename Value, class Point, class Line>
207#if __cpp_concepts >= 201907L
208 requires ProjectivePlaneDual<Value, Point, Line>
209#endif
210 constexpr auto involution(const Point& origin, const Line& mirror, const Point& pt_p) -> Point {
211 const auto po = pt_p.meet(origin);
212 const auto pt_b = po.meet(mirror);
213 return harm_conj(origin, pt_b, pt_p);
214 }
215
216 /*
217 axiom(Point pt_p, Point pt_q, Point pt_r, Line ln_l) {
218 ln_l == Line{pt_p, pt_q} => I(pt_p, ln_l) and I(pt_q, ln_l);
219 }
220 */
221
222} // namespace fun
Definition ck_concepts.hpp:11
constexpr auto check_pappus(const std::array< Point, 3 > &coline1, const std::array< Point, 3 > &coline2) -> bool
Check Pappus Theorem.
Definition pg_plane.hpp:68
constexpr auto persp(const std::array< Point, 3 > &tri1, const std::array< Point, 3 > &tri2) -> bool
return whether two triangles are perspective
Definition pg_plane.hpp:112
constexpr auto tri_dual(const std::array< Point, 3 > &triangle) -> std::array< Line, 3 >
Dual of triangle.
Definition pg_plane.hpp:93
constexpr auto harm_conj(const Point &pt_a, const Point &pt_b, const Point &pt_c) -> Point
Harmonic conjugate.
Definition pg_plane.hpp:184
auto check_axiom(const Point &pt_p, const Point &pt_q, const Line &ln_l) -> bool
Check Projective plane Axiom.
Definition pg_plane.hpp:28
constexpr auto meet(const pg_line< _K > &ln_l, const pg_line< _K > &ln_m) -> pg_point< _K >
Definition pg_line.hpp:53
constexpr auto coincident(const Point &pt_p, const Point &pt_q, const Point &pt_r) -> bool
Coincident.
Definition pg_plane.hpp:51
constexpr auto check_desargue(const std::array< Point, 3 > &tri1, const std::array< Point, 3 > &tri2) -> bool
Check Desargue's Theorem.
Definition pg_plane.hpp:133
auto check_axiom2(const Point &pt_p, const Point &pt_q, const Line &ln_l, const Value &a, const Value &b) -> bool
Check Axiom 2 for extended projective plane properties.
Definition pg_plane.hpp:158
constexpr auto involution(const Point &origin, const Line &mirror, const Point &pt_p) -> Point
Involution on a point.
Definition pg_plane.hpp:210
C++20 concepts for projective plane primitives.