On 05/12/2013 at 12:36, xxxxxxxx wrote:
Hello all,
I'm working with Python trying to make some code where it takes a spline, and I can return a new spline that looks similar but with a number of points that the user inputs.
for y in range(len(points)) :
x = 1/len(points)*y
point = spline.GetSplinePoint(x)
tangent =spline.GetSplineTangent(x)
So I've been testing it on a circle spline.
# The circle tangents are:
tangent1a = c4d.Vector(0,-83,0)
tangent1b = c4d.Vector(0,83,0)
tangent2a = c4d.Vector(83,0,0)
tangent2b = c4d.Vector(-83,0,0)
tangent3a = c4d.Vector(0,83,0)
tangent3b = c4d.Vector(0,-83,0)
tangent4a = c4d.Vector(-83,0,0)
tangent4b = c4d.Vector(83,0,0)
So my spline is in the middle, I have it returning the spline with four points, so if it was working correcting they should look the same. GetSplineTangent() seems to be returning the directions for the handles, but not the amount.
# My tangents are:
tangent1a = c4d.Vector(0,-1,0)
tangent1b = c4d.Vector(0,1,0)
tangent2a = c4d.Vector(1,0,0)
tangent2b = c4d.Vector(-1,0,0)
tangent3a = c4d.Vector(0,1,0)
tangent3b = c4d.Vector(0,-1,0)
tangent4a = c4d.Vector(-1,0,0)
tangent4b = c4d.Vector(1,0,0)
I multiplied the tangent that was returned so I could show that they're the same direction.
# The my new tangents are:
tangent1a = c4d.Vector(0,-20,0)
tangent1b = c4d.Vector(0,20,0)
tangent2a = c4d.Vector(20,0,0)
tangent2b = c4d.Vector(-20,0,0)
tangent3a = c4d.Vector(0,20,0)
tangent3b = c4d.Vector(0,-20,0)
tangent4a = c4d.Vector(-20,0,0)
tangent4b = c4d.Vector(20,0,0)
So my question is how would I find the amount I need to multiple the tangent to get the correct one? It seems proportional to the distance between that point and the neighboring points, but I can't figure out the specifics. In this case I would need to multiple by 83 and then it would be correct, but I'm not sure how to dynamically figure that out.
Sorry for the long post,
Dan