31 using Mat3x3 = std::array<std::array<Fraction, 3>, 3>;
49 static constexpr auto circle(std::int64_t center_x, std::int64_t center_y,
50 std::int64_t radius_sq) ->
Conic {
59 {{-cx, -cy, cx * cx + cy * cy - r2}},
99 const auto& m = matrix_;
100 const auto val = x * (m[0][0] * x + m[0][1] * y + m[0][2] * z)
101 + y * (m[1][0] * x + m[1][1] * y + m[1][2] * z)
102 + z * (m[2][0] * x + m[2][1] * y + m[2][2] * z);
114 const Fraction x{point.coord[0], 1};
115 const Fraction y{point.coord[1], 1};
116 const Fraction z{point.coord[2], 1};
118 const auto& m = matrix_;
119 const auto a = m[0][0] * x + m[0][1] * y + m[0][2] * z;
120 const auto b = m[1][0] * x + m[1][1] * y + m[1][2] * z;
121 const auto c = m[2][0] * x + m[2][1] * y + m[2][2] * z;
123 return PgLine{{a.numer() / a.denom(), b.numer() / b.denom(), c.numer() / c.denom()}};
145 return PgPoint{{line.
coord[0], line.coord[1], line.coord[2]}};
168 return matrix_[0][0] * matrix_[1][1] - matrix_[0][1] * matrix_[1][0];
186 return matrix_ == other.matrix_;
PG Line.
Definition pg_object.hpp:250
PG Point.
Definition pg_object.hpp:235
A conic section represented by a symmetric 3x3 matrix.
Definition conic.hpp:29
constexpr auto tangent(const PgPoint &point) const -> PgLine
Tangent line at a point on the conic.
Definition conic.hpp:134
constexpr auto contains(const PgPoint &point) const -> bool
Check whether a point lies on the conic.
Definition conic.hpp:94
constexpr Conic(Mat3x3 matrix)
Construct a new Conic from a symmetric matrix.
Definition conic.hpp:37
auto intersect(const PgLine &line) const -> std::vector< PgPoint >
Intersection of a line with the conic (placeholder).
Definition conic.hpp:155
static constexpr auto unit_circle() -> Conic
Create a unit circle centred at the origin.
Definition conic.hpp:69
constexpr auto operator==(const Conic &other) const -> bool
Definition conic.hpp:185
constexpr auto pole(const PgLine &line) const -> PgPoint
Pole of a line with respect to the conic (placeholder).
Definition conic.hpp:144
constexpr auto matrix() const -> const Mat3x3 &
Access the matrix.
Definition conic.hpp:183
static constexpr auto parabola(const Fraction &a) -> Conic
Create a parabola .
Definition conic.hpp:76
static constexpr auto circle(std::int64_t center_x, std::int64_t center_y, std::int64_t radius_sq) -> Conic
Create a circle with centre (cx, cy) and squared radius r².
Definition conic.hpp:49
constexpr auto polar(const PgPoint &point) const -> PgLine
Polar line of a point with respect to the conic.
Definition conic.hpp:113
constexpr auto conic_type() const -> ConicType
Determine the conic type from the discriminant.
Definition conic.hpp:175
constexpr auto discriminant() const -> Fraction
Discriminant of the conic (det of the 2x2 upper-left block).
Definition conic.hpp:167
std::array< std::array< Fraction, 3 >, 3 > Mat3x3
Definition conic.hpp:31
Definition ck_concepts.hpp:11
ConicType
Enumeration of conic types based on the discriminant.
Definition conic.hpp:21
Core projective geometry object template (pg_object, PgObject, PgPoint, PgLine).
std::array< int64_t, 3 > coord
Definition pg_object.hpp:132
Fraction.
Definition fractions.hpp:92