QuadBez

from kurbopy import QuadBez, Point

bez = QuadBez(
   Point(50.0, 100.0),
   Point(75.0, 100.0),
   Point(100.0, 100.0),
)
class kurbopy.QuadBez

A single quadratic Bézier segment.

arclen(accuracy)

The arc length of the curve.

The result is accurate to the given accuracy (subject to roundoff errors for ridiculously low values). Compute time may vary with accuracy, if the curve needs to be subdivided.

area()

Compute the signed area under the curve.

For a closed path, the signed area of the path is the sum of signed areas of the segments. This is a variant of the “shoelace formula.” See: <https://github.com/Pomax/bezierinfo/issues/44> and <http://ich.deanmcnamee.com/graphics/2016/03/30/CurveArea.html>

This can be computed exactly for Béziers thanks to Green’s theorem, and also for simple curves such as circular arcs. For more exotic curves, it’s probably best to subdivide to cubics. We leave that to the caller, which is why we don’t give an accuracy param here.

bounding_box()

The smallest rectangle that encloses the shape.

curvature(t)

Compute the signed curvature at parameter t.

deriv()

The derivative of the curve.

Note that the type of the return value is somewhat inaccurate, as the derivative of a curve (mapping of param to point) is a mapping of param to vector. We choose to accept this rather than have a more complex type scheme.

end()

The end point.

eval(t)

Evaluate the curve at parameter t.

Generally t is in the range [0..1].

extrema()

Compute the extrema of the curve.

Only extrema within the interior of the curve count.

The extrema should be reported in increasing parameter order.

inv_arclen(arclen, accuracy)

Solve for the parameter that has the given arc length from the start.

This implementation uses the IPT method, as provided by [common::solve_itp]. This is as robust as bisection but typically converges faster. In addition, the method takes care to compute arc lengths of increasingly smaller segments of the curve, as that is likely faster than repeatedly computing the arc length of the segment starting at t=0.

is_finite()

Is this cubic Bezier curve finite?

is_nan()

Is this cubic Bezier curve NaN?

nearest(point, accuracy)

Find the position on the curve that is nearest to the given point.

This returns a tuple (t, distance_sq) where t is the position on the curve of the nearest point, as a parameter, and distance_sq is the square of the distance from the nearest position on the curve to the given point.

p0
p1
p2
perimeter(accuracy)

Total length of perimeter.

raise()

Raise the order by 1.

Returns a cubic Bézier segment that exactly represents this quadratic.

signed_area()

Compute the signed area under the curve.

For a closed path, the signed area of the path is the sum of signed areas of the segments. This is a variant of the “shoelace formula.” See: _<https://github.com/Pomax/bezierinfo/issues/44> and _<http://ich.deanmcnamee.com/graphics/2016/03/30/CurveArea.html>

This can be computed exactly for Béziers thanks to Green’s theorem, and also for simple curves such as circular arcs. For more exotic curves, it’s probably best to subdivide to cubics. We leave that to the caller, which is why we don’t give an accuracy param here.

start()

The start point.

subsegment()

Get a subsegment of the curve for the given parameter range.

winding(pt)

The winding number of a point.

This method only produces meaningful results with closed shapes.

The sign of the winding number is consistent with that of area, meaning it is +1 when the point is inside a positive area shape and -1 when it is inside a negative area shape. Of course, greater magnitude values are also possible when the shape is more complex.