Ask Your Question

Revision history [back]

Hi,

I used some numerical integration (by hand) and without find_roots. It works quite well and quite fast.

x(t) = 2*cos(t) - cos(2*t)
y(t) = 2*sin(t) - sin(2*t)

dx(t) = x.derivative(t)
dy(t) = y.derivative(t)

arc_length = fast_callable(sqrt(dx(t)**2 + dy(t)**2), vars=(t,), domain=RR)

First I make an approximation of the total length of my curve

total_length = 0.0
for s in xsrange(0,2*pi,0.001):
    total_length += arc_length(s) * 0.001

And then it is possible to store equally spaced points (here 20)

nb_pts = 20
step = total_length / nb_pts
length = 0.
next_pt = step
L = [(x(0),y(0))]
for s in xsrange(0,2*pi,0.001):
    length += arc_length(s) * 0.001
    if length >= next_pt:
        L.append((x(s),y(s)))
        next_pt += step

And

parametric_plot((x(t),y(t)), (t,0,2*pi)) + point2d(L, color='red', pointsize=20)

image description