I found a way to speed up the brute force approach though. If you can use external Python modules:
from scipy import spatial tree = spatial.KDTree(t_list) # t_list is a list of pre-calculated point coordinate tuples on the cubic curve distance, index = tree.query(pt) # pt is the given point coordinate tuple t_for_pt = float(index) / (len(tree.data) - 1)
t_list must be constructed in a way that the first entry is for
t = 0 and the last entry for
t = 1. It doesn't matter how many points for increments of t you calculate, as long as the index in
t_list is proportional to
t. Smaller increments of
t increase the precision of the result, but the list takes longer to build.