23 template <ProjectivePlaneCoord2 Line>
24 constexpr auto fB(
const Line& line_l) ->
typename Line::Dual {
25 return {line_l[0], line_l[1], 0};
37 template <ProjectivePlaneCoord2 Line>
39 return dot1(line_l, line_m) == 0;
51 template <ProjectivePlaneCoord2 Line>
52 constexpr auto is_parallel(
const Line& line_l,
const Line& line_m) ->
bool {
53 return cross2(line_l, line_m) == 0;
69 template <
typename Po
int,
typename Line>
70 requires ProjectivePlaneCoord<Point, Line>
71 constexpr auto altitude(
const Point& a,
const Line& line_l) -> Line {
72 return a *
fB(line_l);
85 template <ProjectivePlaneCoord2 Po
int>
87 const auto& [a_1, a_2, a_3] = triangle;
124 const auto& [a_1, a_2, a_3] = triangle;
125 const auto t1 =
altitude(a_1, a_2 * a_3);
126 const auto t2 =
altitude(a_2, a_1 * a_3);
155 template <ProjectivePlaneCoord2 Line>
constexpr auto reflect(
const Line& line_m) {
185 template <ProjectivePlaneCoord2 Po
int>
constexpr auto midpoint(
const Point& a,
const Point& b)
200 template <ProjectivePlaneCoord2 Po
int>
202 const auto& [a_1, a_2, a_3] = triangle;
218 template <ProjectivePlaneCoord2 Po
int>
220 const auto lda2 = lda1 * lda1;
221 const auto mu2 = mu1 * mu1;
222 return Point{lda2 - mu2, 2 * lda1 * mu1, lda2 + mu2};
237 template <OrderedRing _Q>
constexpr auto archimedes(
const _Q& a,
const _Q& b,
const _Q& c) {
238 return 4 * a * b -
sq(a + b - c);
257 template <
typename _Q>
constexpr auto cqq(
const _Q& a,
const _Q& b,
const _Q& c,
const _Q& d)
258 -> std::array<_Q, 2> {
259 const auto t1 = 4 * a * b;
260 const auto t2 = 4 * c * d;
261 auto line_m = (t1 + t2) -
sq(a + b - c - d);
262 auto point_p = line_m * line_m - 4 * t1 * t2;
263 return {std::move(line_m), std::move(point_p)};
279 template <
typename T>
constexpr auto Ptolemy(
const T& quad) ->
bool {
280 const auto& [Q12, Q23, Q34, Q14, Q13, Q24] = quad;
281 using _K =
decltype(Q12);
282 return archimedes(Q12 * Q34, Q23 * Q14, Q13 * Q24) == _K(0);
Definition proj_plane.hpp:202
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_midpoint(const Triple< Point > &triangle) -> Triple< Point >
Compute the midpoints of all three sides of a triangle.
Definition euclid_plane.hpp:201
typename T::value_type Value_type
Value type of a type.
Definition common_concepts.h:23
auto cross2(const std::array< _K, 3 > &v_a, const std::array< _K, 3 > &v_b) -> _K
3rd term of Cross product (xy-plane projection)
Definition pg_common.hpp:57
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 archimedes(const _Q &a, const _Q &b, const _Q &c)
Archimedes's function.
Definition euclid_plane.hpp:237
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 uc_point(const Value_type< Point > &lda1, const Value_type< Point > &mu1)
Compute a point on the unit circle from trigonometric parameters.
Definition euclid_plane.hpp:219
constexpr auto cqq(const _Q &a, const _Q &b, const _Q &c, const _Q &d) -> std::array< _Q, 2 >
Cyclic quadrilateral quadrea theorem.
Definition euclid_plane.hpp:257
constexpr auto fB(const Line &line_l) -> typename Line::Dual
Convert a line to its direction vector in the affine plane.
Definition euclid_plane.hpp:24
std::array< Point, 3 > Triple
Type alias for an array of three points (a triangle)
Definition proj_plane.hpp:58
auto dot1(const std::array< _K, 3 > &v_a, const std::array< _K, 3 > &v_b) -> _K
Dot product of the (x,y)-components of two vectors (affine part)
Definition pg_common.hpp:135
constexpr auto midpoint(const Point &a, const Point &b) -> Point
Compute the midpoint of two points.
Definition euclid_plane.hpp:185
constexpr auto Ptolemy(const T &quad) -> bool
Check Ptolemy's theorem for a cyclic quadrilateral.
Definition euclid_plane.hpp:279
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 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 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 is_parallel(const Line &line_l, const Line &line_m) -> bool
Check if two lines are parallel.
Definition euclid_plane.hpp:52
constexpr auto sq(const T &a)
Square function.
Definition pg_common.hpp:164
C++20 concepts for projective planes with coordinate access and parametrization.