52 THROW_RANGEERROR(
"square term coefficient == 0");
66 THROW_RANGEERROR(
"ray^2 < 0");
82 std::vector<Coord>
c(4);
97 THROW_RANGEERROR(
"degenerate circle does not have an inverse unit circle transform");
116 Coord delta = (d ==
X ? std::cos(t) : std::sin(t));
131 for (
unsigned i = 0; i < 4; ++i) {
141 return cdist <= rdist;
151 if (
delta >= 0)
return true;
159 return cdist <= rsum;
172 std::vector<ShapeIntersection>
result;
175 Coord ix = (
D*dy) / (dr*dr);
176 Coord iy = (-
D*dx) / (dr*dr);
183 Coord signmod = dy < 0 ? -1 : 1;
185 Coord i1x = (
D*dy + signmod * dx * sqrt_delta) / (dr*dr);
186 Coord i1y = (-
D*dx + fabs(dy) * sqrt_delta) / (dr*dr);
189 Coord i2x = (
D*dy - signmod * dx * sqrt_delta) / (dr*dr);
190 Coord i2y = (-
D*dx - fabs(dy) * sqrt_delta) / (dr*dr);
207 std::vector<ShapeIntersection>
result;
209 if (*
this == other) {
210 THROW_INFINITESOLUTIONS();
225 result.emplace_back(T, t, px);
231 Coord q = (d*d - r*r +
R*
R) / (2*d);
238 Coord h = std::sqrt(
R*
R - q*q);
258 return e.
arc(initial,
inner,
final);
284 size_t sz = points.size();
286 THROW_RANGEERROR(
"fitting error: too few points passed");
289 _center = points[0] * 0.5 + points[1] * 0.5;
297 for (
size_t i = 0; i < sz; ++i) {
298 fitter.append(points[i]);
303 model.
instance(*
this, fitter.result(z));
Set of all points at a fixed distance from the center.
Point initialPoint() const
bool operator==(Circle const &other) const
bool intersects(Line const &l) const
EllipticalArc * arc(Point const &initial, Point const &inner, Point const &final) const
Zoom inverseUnitCircleTransform() const
std::vector< ShapeIntersection > intersect(Line const &other) const
Coord valueAt(Coord t, Dim2 d) const
D2< SBasis > toSBasis() const
Coord timeAt(Point const &p) const
Zoom unitCircleTransform() const
void fit(std::vector< Point > const &points)
Fit the circle to the passed points using the least squares method.
bool contains(Point const &p) const
Coord nearestTime(Point const &p) const
std::vector< Coord > coefficients() const
void setCoefficients(Coord A, Coord B, Coord C, Coord D)
Point pointAt(Coord t) const
Adaptor that creates 2D functions from 1D ones.
Set of points with a constant sum of distances from two foci.
EllipticalArc * arc(Point const &ip, Point const &inner, Point const &fp)
Create an elliptical arc from a section of the ellipse.
CPoint corner(unsigned i) const
Return the n-th corner of the rectangle.
Infinite line on a plane.
Coord timeAt(Point const &p) const
Get a time value corresponding to a point.
Point vector() const
Get the line's raw direction vector.
Point initialPoint() const
Function that interpolates linearly between two values.
void instance(Circle &c, ConstVectorView const &coeff) const
Two-dimensional point that doubles as a vector.
Coord length() const
Compute the distance from origin.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
constexpr Point cw() const
Return a point like this point but rotated +90 degrees.
Axis aligned, non-empty rectangle.
Combination of a translation and uniform scale.
double inner(valarray< double > const &x, valarray< double > const &y)
constexpr Coord lerp(Coord t, Coord a, Coord b)
Numerically stable linear interpolation.
Dim2
2D axis enumeration (X or Y).
double Coord
Floating point type used to store coordinates.
Various utility functions.
SBasisN< n > cos(LinearN< n > bo, int k)
std::ostream & operator<<(std::ostream &os, const Bezier &b)
Angle distance(Angle const &a, Angle const &b)
double atan2(Point const &p)
std::string format_coord_nice(Coord x)
void filter_line_segment_intersections(std::vector< ShapeIntersection > &xs, bool a=false, bool b=true)
Removes intersections outside of the unit interval.
Piecewise< SBasis > cross(Piecewise< D2< SBasis > > const &a, Piecewise< D2< SBasis > > const &b)
SBasisN< n > sin(LinearN< n > bo, int k)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)