ProjGeom 1.0.11
Loading...
Searching...
No Matches
persp_plane.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "ck_plane.hpp"
8#include "fractions.hpp"
9// #include "pg_common.hpp"
10#include "proj_plane.hpp" // import pg_point, Involution, tri_func,
11
12namespace fun {
13
21 template <typename Point, typename Line = typename Point::Dual>
22 requires ProjectivePlanePrim<Point, Line> // c++20 concept
23 class persp_euclid_plane : public ck<Point, Line, persp_euclid_plane> {
24 using K = Value_type<Point>;
25
26 private:
27 Point _I_re;
28 Point _I_im;
29 Line _l_inf;
30
31 public:
35 constexpr persp_euclid_plane(Point I_re, Point I_im, Line l_inf)
36 : _I_re{std::move(I_re)}, _I_im{std::move(I_im)}, _l_inf{std::move(l_inf)} {}
37
38 // constexpr persp_euclid_plane(const Point &I_re, const Point &I_im, const
39 // Line &l_inf)
40 // : _I_re{I_re}, _I_im{I_im}, _l_inf{l_inf} {}
41
42 [[nodiscard]] constexpr auto l_inf() const -> const Line& { return this->_l_inf; }
43
55 [[nodiscard]] constexpr auto perp(const Line& v) const -> Point {
56 const auto alpha = v.dot(this->_I_re);
57 const auto beta = v.dot(this->_I_im);
58 return parametrize(alpha, this->_I_re, beta, this->_I_im);
59 }
60
68 [[nodiscard]] constexpr auto is_parallel(const Line& ln_l, const Line& ln_m) const -> bool {
69 return incident(this->_l_inf, ln_l * ln_m);
70 }
71
83 [[nodiscard]] constexpr auto midpoint(const Point& pt_a, const Point& pt_b) const -> Point {
84 const auto alpha = a.dot(this->_l_inf);
85 const auto beta = pt_b.dot(this->_l_inf);
86 return parametrize(alpha, pt_a, beta, pt_b);
87 }
88
95 [[nodiscard]] constexpr auto tri_midpoint(const Triple<Point>& triangle) const {
96 const auto& [a_1, a_2, a_3] = triangle;
97
98 return Triple<Point>{this->midpoint(a_1, a_2), this->midpoint(a_2, a_3),
99 this->midpoint(a_1, a_3)};
100 }
101
112 [[nodiscard]] constexpr auto omega(const Point& x) const -> K {
113 return sq(x.dot(this->_l_inf));
114 }
115
126 [[nodiscard]] constexpr auto omega(const Line& x) const -> K {
127 return sq(x.dot(this->_I_re)) + sq(x.dot(this->_I_im));
128 }
129
141 template <ProjectivePlane2 _Point>
142 [[nodiscard]] constexpr auto measure(const _Point& a1, const _Point& a2) const {
143 const auto omg = K(this->omega(a1 * a2));
144 const auto den = K(this->omega(a1) * this->omega(a2));
145 if constexpr (Integral<K>) {
146 return Fraction<K>(omg, den);
147 } else {
148 return omg / den;
149 }
150 }
151
152 // /**
153 // * @brief
154 // *
155 // * @param[in] l1
156 // * @param[in] l2
157 // * @return auto
158 // */
159 // constexpr auto cross_s(const Line &l1, const Line &l2) const {
160 // return 1 - this->spread(l1, l2); // ???
161 // }
162 };
163
164} // namespace fun
Cayley-Klein plane functions: perpendicularity, altitude, orthocenter, reflection.
Perspective-Euclidean plane class.
Definition persp_plane.hpp:23
constexpr auto midpoint(const Point &pt_a, const Point &pt_b) const -> Point
Compute the midpoint of two points.
Definition persp_plane.hpp:83
constexpr auto perp(const Line &v) const -> Point
Compute the pole of a line.
Definition persp_plane.hpp:55
constexpr persp_euclid_plane(Point I_re, Point I_im, Line l_inf)
Construct a new persp euclid plane object.
Definition persp_plane.hpp:35
constexpr auto tri_midpoint(const Triple< Point > &triangle) const
Compute the midpoints of all three sides of a triangle.
Definition persp_plane.hpp:95
constexpr auto omega(const Line &x) const -> K
Compute the omega value for a line.
Definition persp_plane.hpp:126
constexpr auto is_parallel(const Line &ln_l, const Line &ln_m) const -> bool
Check if two lines are parallel.
Definition persp_plane.hpp:68
constexpr auto measure(const _Point &a1, const _Point &a2) const
Compute the cross-ratio measure between two elements.
Definition persp_plane.hpp:142
constexpr auto l_inf() const -> const Line &
Definition persp_plane.hpp:42
constexpr auto omega(const Point &x) const -> K
Compute the omega value for a point.
Definition persp_plane.hpp:112
Integral concept.
Definition common_concepts.h:84
Definition ck_concepts.hpp:11
constexpr auto incident(const Point &pt_p, const Line &ln_l) -> bool
The code snippet is defining a function named incident that checks if a point pt_p is incident to a l...
Definition proj_plane.hpp:35
typename T::value_type Value_type
Value type of a type.
Definition common_concepts.h:23
std::array< Point, 3 > Triple
Type alias for an array of three points (a triangle)
Definition proj_plane.hpp:58
constexpr auto parametrize(const Value &lambda_val, const Point &pt_p, const Value &mu_val, const Point &pt_q) -> Point
Homogeneous parametrization of point or line (free function)
Definition pg_common.hpp:185
constexpr auto sq(const T &a)
Square function.
Definition pg_common.hpp:164
Fraction.
Definition fractions.hpp:92