Skip to content

Commit

Permalink
apply fix-format
Browse files Browse the repository at this point in the history
  • Loading branch information
luk036 committed Feb 1, 2024
1 parent f89a5aa commit 9084e52
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 166 deletions.
25 changes: 12 additions & 13 deletions include/projgeom/ck_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <class Point, class Line = typename Point::Dual> concept CayleyKleinPlanePrimitive
= //
template <class Point, class Line = typename Point::Dual>
concept CayleyKleinPlanePrimitive = //
ProjectivePlanePrimitive<Point, Line> //
&&requires(const Point &pt_p, const Line &ln_l) {
{ pt_p.perp() }
->concepts::convertible_to<Line>; // pole or polar
&& requires(const Point &pt_p, const Line &ln_l) {
{ pt_p.perp() } -> concepts::convertible_to<Line>; // pole or polar
};

/**
Expand All @@ -25,21 +24,21 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <class Point, class Line = typename Point::Dual> concept CayleyKleinPlanePrimitiveDual
= CayleyKleinPlanePrimitive<Point, Line> &&CayleyKleinPlanePrimitive<Line, Point>;
template <class Point, class Line = typename Point::Dual>
concept CayleyKleinPlanePrimitiveDual
= CayleyKleinPlanePrimitive<Point, Line> && CayleyKleinPlanePrimitive<Line, Point>;

/**
* @brief Cayley-Klein plane Concept
*
* @tparam Point Point
* @tparam Line Line
*/
template <class Value, class Point, class Line = typename Point::Dual> concept CayleyKleinPlane
= //
template <class Value, class Point, class Line = typename Point::Dual>
concept CayleyKleinPlane = //
ProjectivePlane<Value, Point, Line> //
&&requires(const Point &pt_p, const Line &ln_l) {
{ pt_p.perp() }
->concepts::convertible_to<Line>; // pole or polar
&& requires(const Point &pt_p, const Line &ln_l) {
{ pt_p.perp() } -> concepts::convertible_to<Line>; // pole or polar
};

/**
Expand All @@ -50,6 +49,6 @@ namespace fun {
*/
template <class Value, class Point, class Line = typename Point::Dual>
concept CayleyKleinPlaneDual
= CayleyKleinPlane<Value, Point, Line> &&CayleyKleinPlane<Value, Line, Point>;
= CayleyKleinPlane<Value, Point, Line> && CayleyKleinPlane<Value, Line, Point>;

} // namespace fun
10 changes: 5 additions & 5 deletions include/projgeom/ck_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires CayleyKleinPlanePrimitiveDual<Line, Point>
#endif
constexpr auto is_perpendicular(const Line &m1, const Line &m2) -> bool {
constexpr auto is_perpendicular(const Line &m1, const Line &m2) -> bool {
return m1.perp().incident(m2);
}

Expand All @@ -31,7 +31,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires CayleyKleinPlanePrimitiveDual<Point, Line>
#endif
constexpr auto altitude(const Point &pt_p, const Line &ln_m) -> Line {
constexpr auto altitude(const Point &pt_p, const Line &ln_m) -> Line {
return ln_m.perp().meet(pt_p);
}

Expand All @@ -45,7 +45,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires CayleyKleinPlanePrimitiveDual<Point, Line>
#endif
constexpr auto orthocenter(const std::array<Point, 3> &triangle) -> Point {
constexpr auto orthocenter(const std::array<Point, 3> &triangle) -> Point {
const auto &[a1, a2, a3] = triangle;
assert(!coincident(a1, a2, a3));
const auto t1 = altitude(a1, a2.meet(a3));
Expand All @@ -63,7 +63,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires CayleyKleinPlanePrimitiveDual<Point, Line>
#endif
constexpr auto tri_altitude(const std::array<Point, 3> &triangle) -> std::array<Line, 3> {
constexpr auto tri_altitude(const std::array<Point, 3> &triangle) -> std::array<Line, 3> {
const auto [l1, l2, l3] = tri_dual(triangle);
const auto &[a1, a2, a3] = triangle;
assert(!coincident(a1, a2, a3));
Expand All @@ -77,7 +77,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires CayleyKleinPlaneDual<Value, Point, Line>
#endif
constexpr auto reflect(const Line &mirror, const Point &pt_p) -> Point {
constexpr auto reflect(const Line &mirror, const Point &pt_p) -> Point {
return involution(mirror.perp(), mirror, pt_p);
}

Expand Down
60 changes: 24 additions & 36 deletions include/projgeom/common_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,36 @@ namespace fun {
*
* @tparam T
*/
template <typename T> concept Sequence = requires(T t, Element_type<T> x) {
{ t.size() }
->STD_ALT::convertible_to<std::size_t>;
{ t.empty() }
->STD_ALT::convertible_to<bool>;
{ t.back() }
->STD_ALT::same_as<Element_type<T>>;
template <typename T>
concept Sequence = requires(T t, Element_type<T> x) {
{ t.size() } -> STD_ALT::convertible_to<std::size_t>;
{ t.empty() } -> STD_ALT::convertible_to<bool>;
{ t.back() } -> STD_ALT::same_as<Element_type<T>>;
{t.push_back(x)};
};

template <typename K> concept Ring = STD_ALT::equality_comparable<K> &&requires(K a, K pt_b) {
{ a + pt_b }
->STD_ALT::convertible_to<K>;
{ a - pt_b }
->STD_ALT::convertible_to<K>;
{ a *pt_b }
->STD_ALT::convertible_to<K>;
{ a += pt_b }
->STD_ALT::same_as<K &>;
{ a -= pt_b }
->STD_ALT::same_as<K &>;
{ a *= pt_b }
->STD_ALT::same_as<K &>;
{ -a }
->STD_ALT::convertible_to<K>;
{ K(a) }
->STD_ALT::convertible_to<K>;
{ K(0) }
->STD_ALT::convertible_to<K>;
template <typename K>
concept Ring = STD_ALT::equality_comparable<K> && requires(K a, K pt_b) {
{ a + pt_b } -> STD_ALT::convertible_to<K>;
{ a - pt_b } -> STD_ALT::convertible_to<K>;
{ a *pt_b } -> STD_ALT::convertible_to<K>;
{ a += pt_b } -> STD_ALT::same_as<K &>;
{ a -= pt_b } -> STD_ALT::same_as<K &>;
{ a *= pt_b } -> STD_ALT::same_as<K &>;
{ -a } -> STD_ALT::convertible_to<K>;
{ K(a) } -> STD_ALT::convertible_to<K>;
{ K(0) } -> STD_ALT::convertible_to<K>;
};

template <typename K> concept OrderedRing = Ring<K> &&STD_ALT::totally_ordered<K>;
template <typename K>
concept OrderedRing = Ring<K> && STD_ALT::totally_ordered<K>;

template <typename Z> concept Integral = OrderedRing<Z> &&requires(Z a, Z pt_b) {
{ a % pt_b }
->STD_ALT::convertible_to<Z>;
{ a / pt_b }
->STD_ALT::convertible_to<Z>;
{ a %= pt_b }
->STD_ALT::same_as<Z &>;
{ a /= pt_b }
->STD_ALT::same_as<Z &>;
template <typename Z>
concept Integral = OrderedRing<Z> && requires(Z a, Z pt_b) {
{ a % pt_b } -> STD_ALT::convertible_to<Z>;
{ a / pt_b } -> STD_ALT::convertible_to<Z>;
{ a %= pt_b } -> STD_ALT::same_as<Z &>;
{ a /= pt_b } -> STD_ALT::same_as<Z &>;
};

} // namespace fun
8 changes: 2 additions & 6 deletions include/projgeom/ell_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ class EllipticLine : public PgObject<EllipticLine, EllipticPoint> {
*
* @return EllipticLine
*/
constexpr auto EllipticPoint::perp() const -> EllipticLine {
return EllipticLine{this->coord};
}
constexpr auto EllipticPoint::perp() const -> EllipticLine { return EllipticLine{this->coord}; }

/**
* @brief Pole
*
* @return EllipticPoint
*/
constexpr auto EllipticLine::perp() const -> EllipticPoint {
return EllipticPoint{this->coord};
}
constexpr auto EllipticLine::perp() const -> EllipticPoint { return EllipticPoint{this->coord}; }
6 changes: 2 additions & 4 deletions include/projgeom/euclid_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ namespace fun {
* @return Line
*/
template <typename Point, typename Line>
requires ProjectivePlaneCoord<Point, Line> constexpr auto altitude(const Point &a,
const Line &line_l) -> Line {
return a * fB(line_l);
}
requires ProjectivePlaneCoord<Point, Line>
constexpr auto altitude(const Point &a, const Line &line_l) -> Line { return a * fB(line_l); }

/**
* @brief
Expand Down
17 changes: 7 additions & 10 deletions include/projgeom/euclid_plane_measure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace fun {
* @param[in] z2
* @return auto
*/
template <typename K> requires Integral<K> constexpr auto quad1(const K &x1, const K &z1,
const K &x2,
const K &z2) {
template <typename K>
requires Integral<K>
constexpr auto quad1(const K &x1, const K &z1, const K &x2, const K &z2) {
return sq(Fraction<K>(x1, z1) - Fraction<K>(x2, z2));
}

Expand Down Expand Up @@ -49,7 +49,7 @@ namespace fun {
return quad1(a1[0], a1[2], a2[0], a2[2]) + quad1(a1[1], a1[2], a2[1], a2[2]);
}

template <typename... Args> constexpr auto quadrance_copy(const Args &... args) {
template <typename... Args> constexpr auto quadrance_copy(const Args &...args) {
return std::make_tuple(quadrance(args.first, args.second)...);
}

Expand Down Expand Up @@ -83,8 +83,7 @@ namespace fun {
* @param[in] l2
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
constexpr auto spread(const Line &l1, const Line &l2) {
template <ProjectivePlaneCoord2 Line> constexpr auto spread(const Line &l1, const Line &l2) {
return sbase(l1, l2, cross2(l1, l2));
}

Expand Down Expand Up @@ -119,8 +118,7 @@ namespace fun {
* @param[in] l2
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
constexpr auto cross_s(const Line &l1, const Line &l2) {
template <ProjectivePlaneCoord2 Line> constexpr auto cross_s(const Line &l1, const Line &l2) {
return sbase(l1, l2, dot1(l1, l2));
}

Expand All @@ -133,8 +131,7 @@ namespace fun {
* @param[in] b
* @return auto
*/
template <ProjectivePlaneCoord2 Point>
constexpr auto distance(const Point &a, const Point &b) {
template <ProjectivePlaneCoord2 Point> constexpr auto distance(const Point &a, const Point &b) {
return std::sqrt(double(quadrance(a, b)));
}

Expand Down
2 changes: 1 addition & 1 deletion include/projgeom/persp_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace fun {
*/
template <typename Point, typename Line = typename Point::Dual>
requires ProjectivePlanePrim<Point, Line> // c++20 concept
class persp_euclid_plane : public ck<Point, Line, persp_euclid_plane> {
class persp_euclid_plane : public ck<Point, Line, persp_euclid_plane> {
using K = Value_type<Point>;

private:
Expand Down
4 changes: 2 additions & 2 deletions include/projgeom/pg_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ namespace fun {
* @return Cross product
*/
template <typename Point>
requires Ring<Value_type<Point>> auto cross(const Point &v, const Point &w)
-> std::array<Value_type<Point>, 3> {
requires Ring<Value_type<Point>>
auto cross(const Point &v, const Point &w) -> std::array<Value_type<Point>, 3> {
return {cross0(v, w), -cross1(v, w), cross2(v, w)};
}

Expand Down
39 changes: 19 additions & 20 deletions include/projgeom/pg_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <class Point, class Line> concept ProjectivePlanePrimitive = //
concepts::equality_comparable<Point> //
&&requires(const Point &pt_p, const Point &pt_q, const Line &ln_l) {
{ pt_p.incident(ln_l) }
->concepts::convertible_to<bool>; // incidence
{ pt_p.meet(pt_q) }
->concepts::convertible_to<Line>; // join or meet
template <class Point, class Line>
concept ProjectivePlanePrimitive = //
concepts::equality_comparable<Point> //
&& requires(const Point &pt_p, const Point &pt_q, const Line &ln_l) {
{ pt_p.incident(ln_l) } -> concepts::convertible_to<bool>; // incidence
{ pt_p.meet(pt_q) } -> concepts::convertible_to<Line>; // join or meet
};

/**
Expand All @@ -27,8 +26,9 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <class Point, class Line> concept ProjPlanePrimDual
= ProjectivePlanePrimitive<Point, Line> &&ProjectivePlanePrimitive<Line, Point>;
template <class Point, class Line>
concept ProjPlanePrimDual
= ProjectivePlanePrimitive<Point, Line> && ProjectivePlanePrimitive<Line, Point>;

/**
* @brief Projective plane Concept
Expand All @@ -37,15 +37,13 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <typename Value, class Point, class Line> concept ProjectivePlane
= concepts::equality_comparable<Point> &&ProjectivePlanePrimitive<Point, Line> //
&&requires(const Point &pt_p, const Point &pt_q, const Line &ln_l, const Value &a) {
{ pt_p.aux() }
->concepts::convertible_to<Line>; // line not incident with pt_p
{ pt_p.dot(ln_l) }
->concepts::convertible_to<Value>; // for basic measurement
{ Point::parametrize(a, pt_p, a, pt_q) }
->concepts::convertible_to<Point>;
template <typename Value, class Point, class Line>
concept ProjectivePlane
= concepts::equality_comparable<Point> && ProjectivePlanePrimitive<Point, Line> //
&& requires(const Point &pt_p, const Point &pt_q, const Line &ln_l, const Value &a) {
{ pt_p.aux() } -> concepts::convertible_to<Line>; // line not incident with pt_p
{ pt_p.dot(ln_l) } -> concepts::convertible_to<Value>; // for basic measurement
{ Point::parametrize(a, pt_p, a, pt_q) } -> concepts::convertible_to<Point>;
};

/**
Expand All @@ -55,7 +53,8 @@ namespace fun {
* @tparam Point Point
* @tparam Line Line
*/
template <typename Value, class Point, class Line> concept ProjectivePlaneDual
= ProjectivePlane<Value, Point, Line> &&ProjectivePlane<Value, Line, Point>;
template <typename Value, class Point, class Line>
concept ProjectivePlaneDual
= ProjectivePlane<Value, Point, Line> && ProjectivePlane<Value, Line, Point>;

} // namespace fun
Loading

0 comments on commit 9084e52

Please sign in to comment.