37#ifndef LIB2GEOM_SEEN_ELLIPTICAL_ARC_H
38#define LIB2GEOM_SEEN_ELLIPTICAL_ARC_H
142 double rot_angle,
bool large_arc,
bool sweep,
278 std::vector<double>
roots(
double v,
Dim2 d)
const override;
280 std::vector<double>
allNearestTimes(
Point const& p,
double from = 0,
double to = 1 )
const override;
292 using Curve::operator*=;
304 void feed(
PathSink &sink,
bool moveto_initial)
const override;
312 std::vector<ShapeIntersection>
_filterIntersections(std::vector<ShapeIntersection> &&xs,
bool is_first)
const;
327 double tolerance =
EPSILON,
unsigned num_samples = 20);
Various utility functions.
3x3 affine transformation matrix.
Various trigoniometric helper functions.
3x3 matrix representing an affine transformation.
Directed angular interval.
void setSweep(bool s)
Set whether the interval goes in the direction of increasing angles.
Angle finalAngle() const
Get the end angle.
bool sweep() const
Check whether the interval goes in the direction of increasing angles.
Coord sweepAngle() const
Get the sweep angle of the interval.
Angle angleAt(Coord t) const
Get an angle corresponding to the specified time value.
Coord timeAtAngle(Angle a) const
Compute a time value that would evaluate to the given angle.
Coord extent() const
Extent of the angle interval.
Angle initialAngle() const
Get the start angle.
bool contains(Angle a) const
Check whether the interval includes the given angle.
Wrapper for angular values.
Abstract continuous curve on a plane defined on [0,1].
void transform(Affine const &m)
Transform this curve by an affine transformation.
Adaptor that creates 2D functions from 1D ones.
Set of points with a constant sum of distances from two foci.
void setRays(Point const &p)
Set both rays of the ellipse.
void setRotationAngle(Angle a)
Set the angle the X ray makes with the +X axis.
Angle rotationAngle() const
Get the angle the X ray makes with the +X axis.
Affine unitCircleTransform() const
Compute the transform that maps the unit circle to this ellipse.
Affine inverseUnitCircleTransform() const
Compute the transform that maps this ellipse to the unit circle.
Coord ray(Dim2 d) const
Get one ray of the ellipse.
Point rays() const
Get both rays as a point.
Coord timeAtAngle(Angle a) const
Compute the curve time value corresponding to the given angular value.
int degreesOfFreedom() const override
Return the number of independent parameters required to represent all variations of this curve.
bool isDegenerate() const override
Check whether the curve has exactly zero length.
Rect boundsFast() const override
Quickly compute the curve's approximate bounding box.
bool containsAngle(Angle angle) const
Check whether the arc contains the given angle.
Angle initialAngle() const
std::vector< double > roots(double v, Dim2 d) const override
Computes time values at which the curve intersects an axis-aligned line.
D2< SBasis > toSBasis() const override
Convert the curve to a symmetric power basis polynomial.
bool isLineSegment() const override
Check whether the curve is a line segment.
Point pointAt(Coord t) const override
Evaluate the arc in the curve domain, i.e. .
void set(Point const &ip, double rx, double ry, double rot_angle, bool large_arc, bool sweep, Point const &fp)
Change all of the arc's parameters.
AngleInterval angularInterval() const
Get the angular interval of the arc.
Point finalPoint() const override
Retrieve the end of the curve.
Coord valueAt(Coord t, Dim2 d) const override
Evaluate a single coordinate on the arc in the curve domain.
double nearestTime(Point const &p, double from=0, double to=1) const override
Compute a time value at which the curve comes closest to a specified point.
Curve * reverse() const override
Create a reversed version of this curve.
std::vector< Point > pointAndDerivatives(Coord t, unsigned int n) const override
int winding(Point const &p) const override
Compute the partial winding number of this curve.
Rect boundsExact() const override
Compute bounds of an elliptical arc.
Curve * duplicate() const override
Create an exact copy of this curve.
EllipticalArc(Point const &ip, Coord rx, Coord ry, Coord rot_angle, bool large_arc, bool sweep, Point const &fp)
Create a new elliptical arc, giving the ellipse's rays as separate coordinates.
void _updateCenterAndAngles()
Affine inverseUnitCircleTransform() const
Compute a transform that maps the arc's ellipse to the unit circle.
void feed(PathSink &sink, bool moveto_initial) const override
Feed the curve to a PathSink.
bool largeArc() const
Whether the arc is larger than half an ellipse.
Point initialPoint() const override
Retrieve the start of the curve.
void setFinal(Point const &p) override
Change the ending point of the curve.
void setEndpoints(Point const &ip, Point const &fp)
Change the initial and final point in one operation.
OptRect boundsLocal(OptInterval const &i, unsigned int deg) const override
Coord angularExtent() const
Get the elliptical angle spanned by the arc.
LineSegment chord() const
Get the line segment connecting the arc's endpoints.
Angle rotationAngle() const
Get the defining ellipse's rotation.
bool _validateIntersection(ShapeIntersection &xing, bool is_first) const
Convert the passed intersection to curve time and check whether the intersection is numerically sane.
std::vector< ShapeIntersection > _intersectSameEllipse(EllipticalArc const *other) const
Check if two arcs on the same ellipse intersect/overlap.
bool isChord() const
Check whether both rays are nonzero.
void expandToTransformed(Rect &bbox, Affine const &transform) const override
Expand the given rectangle to include the transformed curve, assuming it already contains its initial...
void set(Point const &ip, Point const &r, Angle rot_angle, bool large_arc, bool sweep, Point const &fp)
Change all of the arc's parameters.
Point rays() const
Get both rays as a point.
Affine unitCircleTransform() const
Compute a transform that maps the unit circle to the arc's ellipse.
std::vector< CurveIntersection > intersect(Curve const &other, Coord eps=EPSILON) const override
Compute intersections with another curve.
Curve * derivative() const override
Create a derivative of this curve.
Angle angleAt(Coord t) const
Compute the angular domain value corresponding to the given time value.
void operator*=(Translate const &tr) override
Point pointAtAngle(Coord t) const
Evaluate the arc at the specified angular coordinate.
EllipticalArc()
Creates an arc with all variables set to zero.
void setInitial(Point const &p) override
Change the starting point of the curve.
Coord center(Dim2 d) const
Get a coordinate of the elliptical arc's center.
Coord ray(Dim2 d) const
Get one of the ellipse's rays.
Coord sweepAngle() const
Compute the amount by which the angle parameter changes going from start to end.
bool _equalTo(Curve const &c) const override
bool sweep() const
Whether the arc turns clockwise.
Point center() const
Get the arc's center.
Coord valueAtAngle(Coord t, Dim2 d) const
Evaluate one of the arc's coordinates at the specified angle.
std::vector< ShapeIntersection > _filterIntersections(std::vector< ShapeIntersection > &&xs, bool is_first) const
Convert the passed intersections to curve time parametrization and filter out any invalid intersectio...
Curve * portion(double f, double t) const override
Create a curve that corresponds to a part of this curve.
std::vector< double > allNearestTimes(Point const &p, double from=0, double to=1) const override
Compute time values at which the curve comes closest to a specified point.
bool isNear(Curve const &other, Coord precision) const override
Test whether two curves are approximately the same.
EllipticalArc(Point const &ip, Point const &r, Coord rot_angle, bool large_arc, bool sweep, Point const &fp)
Create a new elliptical arc.
Intersection between two shapes.
Range of real numbers that can be empty.
Axis-aligned rectangle that can be empty.
Callback interface for processing path data.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Rotation around the origin.
Symmetric power basis curve.
OptRect boundsLocal(OptInterval const &i, unsigned deg) const override
Combination of a translation and uniform scale.
BezierCurveN< 1 > LineSegment
Line segment.
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.
std::ostream & operator<<(std::ostream &os, const Bezier &b)
bool arc_from_sbasis(EllipticalArc &ea, D2< SBasis > const &in, double tolerance, unsigned num_samples)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
Symmetric power basis curve.