34#ifndef LIB2GEOM_SEEN_CONICSEC_H
35#define LIB2GEOM_SEEN_CONICSEC_H
128 xAx (
double c0,
double c1,
double c2,
double c3,
double c4,
double c5)
130 set (c0, c1, c2, c3, c4, c5);
149 xAx (std::vector<Point>
const& points)
167 xAx (
const Point& _vertex,
double _angle,
double _dist1,
double _dist2)
169 set (_vertex, _angle, _dist1, _dist2);
181 set(_vertex, _focus1, _focus2);
193 xAx (
const Point & _focus,
const Line & _directrix,
double _eccentricity)
195 set (_focus, _directrix, _eccentricity);
212 void set (
double c0,
double c1,
double c2,
double c3,
double c4,
double c5)
214 c[0] = c0;
c[1] = c1;
c[2] = c2;
215 c[3] = c3;
c[4] = c4;
224 set(C(0,0), 2*C(1,0), C(1,1), 2*C(2,0), 2*C(2,1), C(2,2));
227 void set (std::vector<Point>
const& points);
229 void set (
const Point& _vertex,
double _angle,
double _dist1,
double _dist2);
233 void set (
const Point & _focus,
const Line & _directrix,
double _eccentricity);
247 return c[0]*x*x +
c[1]*x*y +
c[2]*y*y +
c[3]*x +
c[4]*y +
c[5];
253 return std::vector<double>(
c,
c+6);
258 return c[0]*x*x +
c[1]*x*y +
c[2]*y*y +
c[3]*x*
w +
c[4]*y*
w +
c[5]*
w*
w;
261 xAx scale(
double sx,
double sy)
const;
271 std::optional<RatQuad>
toCurve(
Rect const & bnd)
const;
274 std::vector<double>
roots(
Line const &l)
const;
280 std::optional<Point>
bottom()
const;
292 C(1,0) *= 0.5; C(2,0) *= 0.5; C(2,1) *= 0.5;
343 typedef std::optional<Point> opt_point_t;
346 if (
are_near (d, 0))
return opt_point_t();
350 Q(0,1) = Q(1,0) =
coeff(1) * 0.5;
352 T[0] = -
coeff(3) * 0.5;
353 T[1] = -
coeff(4) * 0.5;
361 return opt_point_t(C);
393 pp[0] = _point[0]; pp[1] = _point[1]; pp[2] = 1;
396 return Line(line[0], line[1], line[2]);
442 const Point & p2)
const
461 if (angle < 0) angle += (2*M_PI);
482 const Point & _inner,
const Point & _final)
const
500 if ( !points.empty() )
502 return points.front();
505 THROW_LOGICALERROR (
"nearestTime: no nearest point found");
511std::vector<Point>
intersect(
const xAx & C1,
const xAx & C2);
513bool clip (std::vector<RatQuad> & rq,
const xAx & cs,
const Rect &
R);
515inline std::ostream &operator<< (std::ostream &out_file,
const xAx &x) {
516 for(
double i : x.
c) {
517 out_file << i <<
", ";
Defines the different types of exceptions that 2geom can throw.
Cartesian point / 2D vector and related operations.
3x3 affine transformation matrix.
Various trigoniometric helper functions.
3x3 matrix representing an affine transformation.
Directed angular interval.
bool contains(Angle a) const
Check whether the interval includes the given angle.
Bezier curve with compile-time specified order.
Adaptor that creates 2D functions from 1D ones.
Range of real numbers that is never empty.
Infinite line on a plane.
const Vector & SV_solve()
Two-dimensional point that doubles as a vector.
void split(RatQuad &a, RatQuad &b) const
RatQuad(Point a, Point b, Point c, double w)
D2< SBasis > hermite() const
static RatQuad circularArc(Point P0, Point P1, Point P2)
static RatQuad fromPointsTangents(Point P0, Point dP0, Point P, Point P2, Point dP2)
CubicBezier toCubic() const
Point pointAt(double t) const
Point P[3]
A curve of the form B02*A + B12*B*w + B22*C/(B02 + B12*w + B22) These curves can exactly represent a ...
std::vector< SBasis > homogeneous() const
Axis aligned, non-empty rectangle.
std::vector< Point > allNearestTimes(const Point &P) const
xAx operator*(double const &b) const
void set(const NL::ConstSymmetricMatrixView< 3 > &C)
static xAx fromDistPoint(Point p, double d)
std::vector< double > implicit_form_coefficients() const
bool decompose(Line &l1, Line &l2) const
xAx rotate(const Point &_rot_centre, double _angle) const
void set(double c0, double c1, double c2, double c3, double c4, double c5)
std::optional< Point > centre() const
std::string categorise() const
@ TWO_IMAGINARY_CROSSING_LINES
@ TWO_REAL_PARALLEL_LINES
@ TWO_REAL_CROSSING_LINES
@ TWO_IMAGINARY_PARALLEL_LINES
static Interval quad_ex(double a, double b, double c, Interval ivl)
bool arc_contains(const Point &_point, const Point &_initial, const Point &_inner, const Point &_final) const
static xAx fromPoints(std::vector< Point > const &pts)
Rect arc_bound(const Point &P1, const Point &Q, const Point &P2) const
static xAx fromPoint(Point p)
double axis_angle() const
Line tangent(const Point &_point) const
std::array< Line, 2 > decompose_df(Coord epsilon=EPSILON) const
Division-free decomposition of a degenerate conic section, without degeneration test.
xAx(const Point &_focus, const Line &_directrix, double _eccentricity)
xAx(std::vector< Point > const &points)
bool is_quadratic() const
xAx translate(const Point &_offset) const
Point nearestTime(const Point &P) const
double coeff(size_t i) const
Point gradient(Point p) const
std::vector< double > roots(Point d, Point o) const
static xAx fromLine(Point n, double d)
NL::SymmetricMatrix< 3 > get_matrix() const
xAx(const Point &_vertex, const Point &_focus1, const Point &_focus2)
T evaluate_at(T x, T y, T w) const
double valueAt(Point P) const
xAx rotate(double angle) const
bool isDegenerate() const
Interval extrema(Rect r) const
xAx(const Point &_vertex, double _angle, double _dist1, double _dist2)
T evaluate_at(T x, T y) const
std::optional< Point > bottom() const
xAx(double c0, double c1, double c2, double c3, double c4, double c5)
std::optional< RatQuad > toCurve(Rect const &bnd) const
xAx operator-(xAx const &b) const
double angle_at(const Point &_point) const
Geom::Affine hessian() const
xAx operator+(xAx const &b) const
std::vector< Point > crossings(Rect r) const
RatQuad toRatQuad(const Point &p0, const Point &p1, const Point &p2) const
xAx(const Line &l1, const Line &l2)
xAx(const NL::ConstSymmetricMatrixView< 3 > &C)
Dim2
2D axis enumeration (X or Y).
double Coord
Floating point type used to store coordinates.
constexpr Coord EPSILON
Default "acceptably small" value.
Various utility functions.
double atan2(Point const &p)
bool clip(std::vector< RatQuad > &rq, const xAx &cs, const Rect &R)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
D2< T > rot90(D2< T > const &a)
std::vector< Point > intersect(const xAx &C1, const xAx &C2)