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¶
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.
- curvature(t)¶
Compute the signed curvature at parameter t.
- 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 line finite?
- is_nan()¶
Is this line 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 tuple
(t, distance_sq)
wheret
is the position on the curve of the nearest point, as a parameter, anddistance_sq
is the square of the distance from the nearest position on the curve to the given point.
- 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.
- subsegment()¶
Get a subsegment of the curve for the given parameter range.