23constexpr auto dot(
const std::array<int64_t, 3>& pt_a,
const std::array<int64_t, 3>& pt_b)
25 return pt_a[0] * pt_b[0] + pt_a[1] * pt_b[1] + pt_a[2] * pt_b[2];
38constexpr auto cross(
const std::array<int64_t, 3>& pt_a,
const std::array<int64_t, 3>& pt_b)
39 -> std::array<int64_t, 3> {
41 pt_a[1] * pt_b[2] - pt_a[2] * pt_b[1],
42 pt_a[2] * pt_b[0] - pt_a[0] * pt_b[2],
43 pt_a[0] * pt_b[1] - pt_a[1] * pt_b[0],
59constexpr auto plckr(
const int64_t& lambda,
const std::array<int64_t, 3>& pt_p,
const int64_t& mu,
60 const std::array<int64_t, 3>& pt_q) -> std::array<int64_t, 3> {
62 lambda * pt_p[0] + mu * pt_q[0],
63 lambda * pt_p[1] + mu * pt_q[1],
64 lambda * pt_p[2] + mu * pt_q[2],
79 template <Ring _K,
typename Self,
typename DualType>
struct pg_object {
87 constexpr pg_object(
const _K& x,
const _K& y,
const _K& z) :
coord{{x, y, z}} {}
89 friend constexpr auto operator==(
const Self& lhs,
const Self& rhs) ->
bool {
91 || (lhs.coord[1] * rhs.coord[2] == lhs.coord[2] * rhs.coord[1]
92 && lhs.coord[2] * rhs.coord[0] == lhs.coord[0] * rhs.coord[2]
93 && lhs.coord[0] * rhs.coord[1] == lhs.coord[1] * rhs.coord[0]);
96 friend constexpr auto operator!=(
const Self& lhs,
const Self& rhs) ->
bool {
100 friend constexpr auto operator*(
const Self& lhs,
const Self& rhs) -> DualType {
101 return DualType{
::cross(lhs.coord, rhs.coord)};
104 constexpr auto aux() const -> DualType {
return DualType{this->coord}; }
106 constexpr auto dot(
const DualType& other)
const -> _K {
107 return this->coord[0] * other.coord[0] + this->coord[1] * other.coord[1]
108 + this->coord[2] * other.coord[2];
111 constexpr auto incident(
const DualType& other)
const ->
bool {
112 return this->
dot(other) == _K(0);
115 static constexpr auto parametrize(
const _K& lambda_val,
const Self& pt_p,
const _K& mu_val,
116 const Self& pt_q) -> Self {
117 return Self{
::plckr(lambda_val, pt_p.coord, mu_val, pt_q.coord)};
129template <
typename Po
int,
typename Line>
struct PgObject {
149 friend constexpr auto operator==(
const Point& lhs,
const Point& rhs) ->
bool {
150 return &lhs == &rhs ? true
151 : lhs.coord[1] * rhs.coord[2] == lhs.coord[2] * rhs.coord[1]
152 && lhs.coord[2] * rhs.coord[0] == lhs.coord[0] * rhs.coord[2]
153 && lhs.coord[0] * rhs.coord[1] == lhs.coord[1] * rhs.coord[0];
164 friend constexpr auto operator!=(
const Point& lhs,
const Point& rhs) ->
bool {
165 return !(lhs == rhs);
173 constexpr auto aux() const -> Line {
return Line{this->coord}; }
184 constexpr auto dot(
const Line& other)
const -> int64_t {
185 return ::dot(this->coord, other.coord);
200 static constexpr auto parametrize(
const int64_t& lambda_val,
const Point& pt_p,
201 const int64_t& mu_val,
const Point& pt_q) -> Point {
202 return Point{
::plckr(lambda_val, pt_p.coord, mu_val, pt_q.coord)};
212 constexpr auto incident(
const Line& other)
const ->
bool {
return this->
dot(other) == 0; }
223 constexpr auto meet(
const Point& rhs)
const -> Line {
224 return Line{
::cross(this->coord, rhs.coord)};
PG Line.
Definition pg_object.hpp:250
constexpr PgLine(std::array< int64_t, 3 > coord)
Construct a new Pg Line object.
Definition pg_object.hpp:257
PG Point.
Definition pg_object.hpp:235
constexpr PgPoint(std::array< int64_t, 3 > coord)
Construct a new Pg Point object.
Definition pg_object.hpp:242
Definition ck_concepts.hpp:11
auto cross(const Point &v_a, const Point &v_b) -> std::array< Value_type< Point >, 3 >
Cross product in homogeneous 3D coordinates.
Definition pg_common.hpp:79
constexpr auto cross(const std::array< int64_t, 3 > &pt_a, const std::array< int64_t, 3 > &pt_b) -> std::array< int64_t, 3 >
Cross product of two homogeneous 3-vectors.
Definition pg_object.hpp:38
constexpr auto plckr(const int64_t &lambda, const std::array< int64_t, 3 > &pt_p, const int64_t &mu, const std::array< int64_t, 3 > &pt_q) -> std::array< int64_t, 3 >
Homogeneous parametrization of point or line.
Definition pg_object.hpp:59
constexpr auto dot(const std::array< int64_t, 3 > &pt_a, const std::array< int64_t, 3 > &pt_b) -> int64_t
Dot product of two homogeneous 3-vectors.
Definition pg_object.hpp:23
Projective plane axioms and geometric checks (coincidence, Pappus, Desargues).
Projective Point/Line (int64_t specialization)
Definition pg_object.hpp:129
constexpr auto incident(const Line &other) const -> bool
Check incidence with the dual object.
Definition pg_object.hpp:212
constexpr auto meet(const Point &rhs) const -> Line
Meet (intersection) with another point to form a line.
Definition pg_object.hpp:223
constexpr auto dot(const Line &other) const -> int64_t
Dot product with the dual object.
Definition pg_object.hpp:184
constexpr auto aux() const -> Line
Return the dual object (auxiliary line/point).
Definition pg_object.hpp:173
std::array< int64_t, 3 > coord
Definition pg_object.hpp:132
static constexpr auto parametrize(const int64_t &lambda_val, const Point &pt_p, const int64_t &mu_val, const Point &pt_q) -> Point
Homogeneous parametrization of point or line.
Definition pg_object.hpp:200
constexpr PgObject(std::array< int64_t, 3 > coord)
Construct a new Pg Object object.
Definition pg_object.hpp:139
friend constexpr auto operator==(const Point &lhs, const Point &rhs) -> bool
Equal to.
Definition pg_object.hpp:149
friend constexpr auto operator!=(const Point &lhs, const Point &rhs) -> bool
Not equal to.
Definition pg_object.hpp:164
Line Dual
Definition pg_object.hpp:130
Generic projective geometry object (value-type templated)
Definition pg_object.hpp:79
friend constexpr auto operator*(const Self &lhs, const Self &rhs) -> DualType
Definition pg_object.hpp:100
constexpr auto dot(const DualType &other) const -> _K
Definition pg_object.hpp:106
static constexpr auto parametrize(const _K &lambda_val, const Self &pt_p, const _K &mu_val, const Self &pt_q) -> Self
Definition pg_object.hpp:115
constexpr pg_object(const _K &x, const _K &y, const _K &z)
Definition pg_object.hpp:87
constexpr pg_object(std::array< _K, 3 > coord)
Definition pg_object.hpp:85
DualType Dual
Definition pg_object.hpp:80
constexpr auto aux() const -> DualType
Definition pg_object.hpp:104
friend constexpr auto operator==(const Self &lhs, const Self &rhs) -> bool
Definition pg_object.hpp:89
constexpr auto incident(const DualType &other) const -> bool
Definition pg_object.hpp:111
_K value_type
Definition pg_object.hpp:81
std::array< _K, 3 > coord
Definition pg_object.hpp:83
friend constexpr auto operator!=(const Self &lhs, const Self &rhs) -> bool
Definition pg_object.hpp:96