I have a question on how/if I could use scipy.odeint for the following; I have a function that approximates a given distance on a nurbs curve. The algorithm is rather crude, so I'd like to generalize and make it more efficient. Scipy.odeint could be a suitable function to do so, but I'm having a hard time implementing it. The function I'd like to integrate with scip.odeint is the following: while 1: print 'approxLengthPLUS',approxLength if abs(distance-approxLength) < tolerance: break if approxLength < distance: tangent = vec3(RS.PointCoordinates(pointIdPLUS)) + vec3(crv.tangent(pointIdPLUS)[2]).normalize() * (1.5*vectorScale) closestPointIdPLUS = crv.closestPoint(tangent) closestCoord = crv.evaluateCrv(closestPointIdPLUS) RS.PointCoordinates(pointIdPLUS, closestCoord) else : tangent = vec3(RS.PointCoordinates(pointIdPLUS)) + vec3(crv.tangent(pointIdMIN)[2]).normalize() * (-0.75*vectorScale) closestPointIdPLUS = crv.closestPoint(tangent) closestCoord = crv.evaluateCrv(closestPointIdPLUS) RS.PointCoordinates(pointIdPLUS, closestCoord) n+=1 approxLength = crv.length(subDomain=[crvParameter, closestPointIdPLUS]) vectorScale = approxLength*(tolerance/n) Which basically scans a nurbs curve back & forth until a point is located within the tolerance. The method crv.closestPoint(tangent) returns the closest parameter of the current point The method crv.length(subDomain=[crvParameter, closestPointIdPLUS]) returns the distance from the starting point, to the point currently evaluated. Any pointers in how I could integrate such a function with scipy are greatly appreciated! Cheers, -jelle
participants (1)
-
Jelle Feringa / EZCT Architecture & Design Research