Skip to content

Commit

Permalink
spell out variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
luk036 committed Aug 15, 2023
1 parent 0f84436 commit 783508a
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 122 deletions.
32 changes: 16 additions & 16 deletions include/projgeom/ck_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ namespace fun {
/**
* @brief C-K plane Concept
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class P, class L = typename P::Dual>
concept CKPlanePrim = //
ProjPlanePrim<P, L> //
&& requires(const P &p, const L &l) {
template <class Point, class L = typename Point::Dual>
concept CayleyKleinPlanePrimitive = //
ProjectivePlanePrimitive<Point, L> //
&& requires(const Point &p, const L &l) {
{ p.perp() } -> concepts::convertible_to<L>;
};

/**
* @brief C-K plane Concept (full)
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class P, class L = typename P::Dual>
concept CKPlanePrimDual = CKPlanePrim<P, L> && CKPlanePrim<L, P>;
template <class Point, class L = typename Point::Dual>
concept CKPlanePrimDual = CayleyKleinPlanePrimitive<Point, L> && CayleyKleinPlanePrimitive<L, Point>;

/**
* @brief C-K plane Concept
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class V, class P, class L = typename P::Dual>
concept CKPlane = //
ProjPlane<V, P, L> //
&& requires(const P &p, const L &l) {
template <class V, class Point, class L = typename Point::Dual>
concept CayleyKleinPlane = //
ProjectivePlane<V, Point, L> //
&& requires(const Point &p, const L &l) {
{ p.perp() } -> concepts::convertible_to<L>;
};

/**
* @brief C-K plane Concept (full)
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class V, class P, class L = typename P::Dual>
concept CKPlaneDual = CKPlane<V, P, L> && CKPlane<V, L, P>;
template <class V, class Point, class L = typename Point::Dual>
concept CKPlaneDual = CayleyKleinPlane<V, Point, L> && CayleyKleinPlane<V, L, Point>;

} // namespace fun
44 changes: 22 additions & 22 deletions include/projgeom/ck_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace fun {
/**
* @brief
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class L, class P = typename L::Dual>
template <class L, class Point = typename L::Dual>
#if __cpp_concepts >= 201907L
requires CKPlanePrimDual<L, P>
requires CKPlanePrimDual<L, Point>
#endif
constexpr auto is_perpendicular(const L &m1, const L &m2) -> bool {
return m1.perp().incident(m2);
Expand All @@ -24,15 +24,15 @@ namespace fun {
/**
* @brief
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class P, class L>
template <class Point, class L>
#if __cpp_concepts >= 201907L
requires CKPlanePrimDual<P, L>
requires CKPlanePrimDual<Point, L>
#endif
constexpr auto altitude(const P &p, const L &m) -> L {
return m.perp().circ(p);
constexpr auto altitude(const Point &p, const L &m) -> L {
return m.perp().meet(p);
}

/**
Expand All @@ -41,17 +41,17 @@ namespace fun {
* @param[in] tri
* @return std::arrary<L, 3>
*/
template <class P, class L = typename P::Dual>
template <class Point, class L = typename Point::Dual>
#if __cpp_concepts >= 201907L
requires CKPlanePrimDual<P, L>
requires CKPlanePrimDual<Point, L>
#endif
constexpr auto orthocenter(const std::array<P, 3> &tri) -> P {
constexpr auto orthocenter(const std::array<Point, 3> &tri) -> Point {
const auto &[a1, a2, a3] = tri;
assert(!coincident(a1, a2, a3));
const auto t1 = altitude(a1, a2.circ(a3));
const auto t2 = altitude(a2, a3.circ(a1));
return t1.circ(t2);
// return {a2.circ(a3), a1.circ(a3), a1.circ(a2)};
const auto t1 = altitude(a1, a2.meet(a3));
const auto t2 = altitude(a2, a3.meet(a1));
return t1.meet(t2);
// return {a2.meet(a3), a1.meet(a3), a1.meet(a2)};
}

/**
Expand All @@ -60,11 +60,11 @@ namespace fun {
* @param[in] tri
* @return std::arrary<L, 3>
*/
template <class P, class L>
template <class Point, class L>
#if __cpp_concepts >= 201907L
requires CKPlanePrimDual<P, L>
requires CKPlanePrimDual<Point, L>
#endif
constexpr auto tri_altitude(const std::array<P, 3> &tri) -> std::array<L, 3> {
constexpr auto tri_altitude(const std::array<Point, 3> &tri) -> std::array<L, 3> {
const auto [l1, l2, l3] = tri_dual(tri);
const auto &[a1, a2, a3] = tri;
assert(!coincident(a1, a2, a3));
Expand All @@ -74,16 +74,16 @@ namespace fun {
return {t1, t2, t3};
}

template <typename V, class P, class L = typename P::Dual>
template <typename V, class Point, class L = typename Point::Dual>
#if __cpp_concepts >= 201907L
requires CKPlaneDual<V, P, L>
requires CKPlaneDual<V, Point, L>
#endif
constexpr auto reflect(const L &mirror, const P &p) -> P {
constexpr auto reflect(const L &mirror, const Point &p) -> Point {
return involution(mirror.perp(), mirror, p);
}

/*
axiom(P p, P q, P r, L l) {
axiom(Point p, Point q, Point r, L l) {
l == L{p, q} => I(p, l) and I(q, l);
}
*/
Expand Down
34 changes: 17 additions & 17 deletions include/projgeom/pg_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,49 @@ namespace fun {
/**
* @brief Projective plane Concept
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class P, class L>
concept ProjPlanePrim = //
concepts::equality_comparable<P> //
&& requires(const P &p, const P &q, const L &l) {
template <class Point, class L>
concept ProjectivePlanePrimitive = //
concepts::equality_comparable<Point> //
&& requires(const Point &p, const Point &q, const L &l) {
{ p.incident(l) } -> concepts::convertible_to<bool>; // incidence
{ p.circ(q) } -> concepts::convertible_to<L>; // join or meet
{ p.meet(q) } -> concepts::convertible_to<L>; // join or meet
};

/**
* @brief Projective plane Concept (full)
*
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <class P, class L>
concept ProjPlanePrimDual = ProjPlanePrim<P, L> && ProjPlanePrim<L, P>;
template <class Point, class L>
concept ProjPlanePrimDual = ProjectivePlanePrimitive<Point, L> && ProjectivePlanePrimitive<L, Point>;

/**
* @brief Projective plane Concept
*
* @tparam V
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <typename V, class P, class L>
concept ProjPlane = concepts::equality_comparable<P> && ProjPlanePrim<P, L> //
&& requires(const P &p, const P &q, const L &l, const V &a) {
template <typename V, class Point, class L>
concept ProjectivePlane = concepts::equality_comparable<Point> && ProjectivePlanePrimitive<Point, L> //
&& requires(const Point &p, const Point &q, const L &l, const V &a) {
{ p.aux() } -> concepts::convertible_to<L>; // line not incident with p
{ p.dot(l) } -> concepts::convertible_to<V>; // for basic measurement
{ P::plucker(a, p, a, q) } -> concepts::convertible_to<P>;
{ Point::plucker(a, p, a, q) } -> concepts::convertible_to<Point>;
};

/**
* @brief Projective plane dual Concept
*
* @tparam V
* @tparam P Point
* @tparam Point Point
* @tparam L Line
*/
template <typename V, class P, class L>
concept ProjPlaneDual = ProjPlane<V, P, L> && ProjPlane<V, L, P>;
template <typename V, class Point, class L>
concept ProjPlaneDual = ProjectivePlane<V, Point, L> && ProjectivePlane<V, L, Point>;

} // namespace fun
18 changes: 9 additions & 9 deletions include/projgeom/pg_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ constexpr auto plckr(const int64_t &ld, const std::array<int64_t, 3> &p, const i
/**
* @brief Projective Point/Line
*
* @tparam P
* @tparam Point
* @tparam L
*/
template <typename P, typename L> struct PgObject {
template <typename Point, typename L> struct PgObject {
using Dual = L;

std::array<int64_t, 3> coord;
Expand All @@ -76,7 +76,7 @@ template <typename P, typename L> struct PgObject {
* @return true
* @return false
*/
friend constexpr auto operator==(const P &lhs, const P &rhs) -> bool {
friend constexpr auto operator==(const Point &lhs, const Point &rhs) -> bool {
return &lhs == &rhs ? true
: lhs.coord[1] * rhs.coord[2] == lhs.coord[2] * rhs.coord[1]
&& lhs.coord[2] * rhs.coord[0] == lhs.coord[0] * rhs.coord[2]
Expand All @@ -90,7 +90,7 @@ template <typename P, typename L> struct PgObject {
* @return true
* @return false
*/
friend constexpr auto operator!=(const P &lhs, const P &rhs) -> bool { return !(lhs == rhs); }
friend constexpr auto operator!=(const Point &lhs, const Point &rhs) -> bool { return !(lhs == rhs); }

/**
* @brief
Expand All @@ -114,11 +114,11 @@ template <typename P, typename L> struct PgObject {
* @param[in] p
* @param[in] mu
* @param[in] q
* @return P
* @return Point
*/
static constexpr auto plucker(const int64_t &ld, const P &p, const int64_t &mu, const P &q)
-> P {
return P{::plckr(ld, p.coord, mu, q.coord)};
static constexpr auto plucker(const int64_t &ld, const Point &p, const int64_t &mu, const Point &q)
-> Point {
return Point{::plckr(ld, p.coord, mu, q.coord)};
}

/**
Expand All @@ -136,7 +136,7 @@ template <typename P, typename L> struct PgObject {
* @param[in] rhs
* @return L
*/
constexpr auto circ(const P &rhs) const -> L { return L{::cross(this->coord, rhs.coord)}; }
constexpr auto meet(const Point &rhs) const -> L { return L{::cross(this->coord, rhs.coord)}; }
};

class PgPoint;
Expand Down
Loading

0 comments on commit 783508a

Please sign in to comment.