ProjGeom 1.0.11
Loading...
Searching...
No Matches
euclid_plane_measure.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "euclid_plane.hpp"
8// #include "fractions.hpp"
9
10namespace fun {
11
24 template <typename K>
25 requires Integral<K>
26 constexpr auto quad1(const K& x1, const K& z1, const K& x2, const K& z2) {
27 return sq(Fraction<K>(x1, z1) - Fraction<K>(x2, z2));
28 }
29
38 template <typename K>
39 // requires (!Integral<K>)
40 constexpr auto quad1(const K& x1, const K& z1, const K& x2, const K& z2) {
41 return sq(x1 / z1 - x2 / z2);
42 }
43
76 template <ProjectivePlaneCoord2 Point>
77 constexpr auto quadrance(const Point& a1, const Point& a2) {
78 return quad1(a1[0], a1[2], a2[0], a2[2]) + quad1(a1[1], a1[2], a2[1], a2[2]);
79 }
80
88 template <typename... Args> constexpr auto quadrance_copy(const Args&... args) {
89 return std::make_tuple(quadrance(args.first, args.second)...);
90 }
91
92 // ProjectivePlane2 { Line }
93 // constexpr auto sbase(const Line &l1, const Line &l2, const Integer &d) {
94 // return Fraction(d, omgB(l1, l1)) * Fraction(d, omgB(l2, l2));
95 // }
96
109 template <ProjectivePlaneCoord2 Line, typename T>
110 constexpr auto sbase(const Line& l1, const Line& l2, const T& d) {
111 using K = Value_type<Line>;
112 if constexpr (Integral<K>) {
113 return Fraction<K>(d, dot1(l1, l1)) * Fraction<K>(d, dot1(l2, l2));
114 } else {
115 return (d * d) / (dot1(l1, l1) * dot1(l2, l2));
116 }
117 }
118
150 template <ProjectivePlaneCoord2 Line> constexpr auto spread(const Line& l1, const Line& l2) {
151 return sbase(l1, l2, cross2(l1, l2));
152 }
153
161 template <ProjectivePlaneCoord2 Point>
162 constexpr auto tri_quadrance(const Triple<Point>& triangle) {
163 const auto& [a_1, a_2, a_3] = triangle;
164 return std::array{quadrance(a_2, a_3), quadrance(a_1, a_3), quadrance(a_1, a_2)};
165 }
166
174 template <ProjectivePlaneCoord2 Line>
175 constexpr auto tri_spread(const Triple<Line>& trilateral) {
176 const auto& [a_1, a_2, a_3] = trilateral;
177 return std::array{spread(a_2, a_3), spread(a_1, a_3), spread(a_1, a_2)};
178 }
179
193 template <ProjectivePlaneCoord2 Line> constexpr auto cross_s(const Line& l1, const Line& l2) {
194 return sbase(l1, l2, dot1(l1, l2));
195 }
196
197} // namespace fun
Integral concept.
Definition common_concepts.h:84
Euclidean plane functions: perpendicularity, parallelism, altitude, orthocenter, etc.
Definition ck_concepts.hpp:11
constexpr auto quad1(const K &x1, const K &z1, const K &x2, const K &z2)
Compute squared difference of ratios (integral version).
Definition euclid_plane_measure.hpp:26
constexpr auto tri_quadrance(const Triple< Point > &triangle)
Compute the quadrances of a triangle's sides.
Definition euclid_plane_measure.hpp:162
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 quadrance_copy(const Args &... args)
Compute quadrances for multiple pairs of points.
Definition euclid_plane_measure.hpp:88
constexpr auto tri_spread(const Triple< Line > &trilateral)
Compute the spreads of a triangle's angles.
Definition euclid_plane_measure.hpp:175
constexpr auto cross_s(const Line &l1, const Line &l2)
Compute the cross spread between two lines.
Definition euclid_plane_measure.hpp:193
constexpr auto sbase(const Line &l1, const Line &l2, const T &d)
Base function for spread and cross-spread.
Definition euclid_plane_measure.hpp:110
std::array< Point, 3 > Triple
Type alias for an array of three points (a triangle)
Definition proj_plane.hpp:58
constexpr auto quadrance(const Point &a1, const Point &a2)
Compute the quadrance between two points.
Definition euclid_plane_measure.hpp:77
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 spread(const Line &l1, const Line &l2)
Compute the spread between two lines.
Definition euclid_plane_measure.hpp:150
constexpr auto sq(const T &a)
Square function.
Definition pg_common.hpp:164
Fraction.
Definition fractions.hpp:92