ProjGeom 1.0.11
Loading...
Searching...
No Matches
proj_plane_measure.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "fractions.hpp"
4#include "proj_plane.hpp"
5
14namespace fun {
15
28 template <Ring K> constexpr auto ratio_ratio(const K& a, const K& b, const K& c, const K& d) {
29 if constexpr (Integral<K>) {
30 return Fraction(a, b) / Fraction(c, d);
31 } else {
32 return (a * d) / (b * c);
33 }
34 }
35
53 template <typename Point, typename Line>
54 requires ProjectivePlane<Point, Line>
55 constexpr auto x_ratio(const Point& A, const Point& B, const Line& line_l, const Line& line_m) {
56 return ratio_ratio(A.dot(line_l), A.dot(line_m), B.dot(line_l), B.dot(line_m));
57 }
58
77 template <ProjectivePlaneCoord2 Point>
78 constexpr auto R(const Point& A, const Point& B, const Point& C, const Point& D)
79
80 {
81 using K = Value_type<Point>;
82 if (cross0(A, B) != K(0)) { // Project points to yz-plane
83 return R0(A, B, C, D);
84 }
85 // Project points to xz-plane
86 return R1(A, B, C, D);
87 }
88
96 template <ProjectivePlane2 Point>
97 constexpr auto R(const Point& A, const Point& B, const Point& C, const Point& D) {
98 const auto O = (C * D).aux();
99 return x_ratio(A, B, O * C, O * D);
100 }
101
116 template <ProjectivePlaneCoord2 Point>
117 constexpr auto R0(const Point& A, const Point& B, const Point& C, const Point& D) {
118 return ratio_ratio(cross0(A, C), cross0(A, D), cross0(B, C), cross0(B, D));
119 }
120
135 template <ProjectivePlaneCoord2 Point>
136 constexpr auto R1(const Point& A, const Point& B, const Point& C, const Point& D) {
137 return ratio_ratio(cross1(A, C), cross1(A, D), cross1(B, C), cross1(B, D));
138 }
139
140} // namespace fun
Integral concept.
Definition common_concepts.h:84
Definition ck_concepts.hpp:11
constexpr auto R1(const Point &A, const Point &B, const Point &C, const Point &D)
Compute cross ratio using xz-plane projection.
Definition proj_plane_measure.hpp:136
auto cross0(const std::array< _K, 3 > &v_a, const std::array< _K, 3 > &v_b) -> _K
1st term of Cross product (yz-plane projection)
Definition pg_common.hpp:25
constexpr auto R0(const Point &A, const Point &B, const Point &C, const Point &D)
Compute cross ratio using yz-plane projection.
Definition proj_plane_measure.hpp:117
typename T::value_type Value_type
Value type of a type.
Definition common_concepts.h:23
constexpr auto R(const Point &A, const Point &B, const Point &C, const Point &D)
Compute the cross ratio of four collinear points.
Definition proj_plane_measure.hpp:78
constexpr auto x_ratio(const Point &A, const Point &B, const Line &line_l, const Line &line_m)
Cross Ratio.
Definition proj_plane_measure.hpp:55
constexpr auto ratio_ratio(const K &a, const K &b, const K &c, const K &d)
Compute the ratio of two ratios.
Definition proj_plane_measure.hpp:28
auto cross1(const std::array< _K, 3 > &v_a, const std::array< _K, 3 > &v_b) -> _K
2nd term of Cross product (xz-plane projection)
Definition pg_common.hpp:41
Fraction.
Definition fractions.hpp:92