Line¶
from kurbopy import Line
pt_from = Point(50.0, 100.0)
pt_to = Point(100.0, 120.0)
l = Line(pt_from, pt_to)
- class kurbopy.Line(p0, p1)¶
A single line.
- 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.
- bounding_box()¶
The smallest rectangle that encloses the curve in the range (0..1).
- crossing_point(other)¶
Computes the point where two lines, if extended to infinity, would cross
- curvature(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.
- extrema_ranges()¶
Return parameter ranges, each of which is monotonic within the range.
- 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 value finite?
- is_nan()¶
Is this value NaN?
- length()¶
The length of the line.
- nearest(point, accuracy)¶
Find the position on the curve that is nearest to the given point.
This returns a [Nearest] struct that contains information about the position.
- p0¶
- p1¶
- 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.
- subdivide()¶
Subdivide into (roughly) halves.
- subsegment()¶
Get a subsegment of the curve for the given parameter range.