How get a tangent vector of a baked point belonging to a curve3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By simLC

Hello, as the tile says I’m looking for a curve3D function which, given a 3D points belonging to the curve, returns the tangent vector of the curve at this point. Ideally, this would be a unit vector.

Do you know if a function like this is available? I looked in the docs but didn’t find something usefull. I don’t really understand the definition of the up vectors…

If I don’t find solution, I plan to make a vector with an another point close to the first one, but it is not perfect…

Thanks for your answers, I’ll appreciate all of them !

See you ! Simon

:bust_in_silhouette: Reply From: Zylann

I think if you want the tangent of two baked points, you would need to derive it yourself.
One way to do this is to take two points slightly off from the point you want, take their difference, normalize it and you should obtain a vector looking along the curve at that point (either forward or backward depending on the order you sampled the points). If that’s what you expect a tangent to be :stuck_out_tongue:

var point = curve.interpolate_baked(offset)
var point2 = curve.interpolate_baked(offset + 0.001)
var dir = (point2 - point).normalized()

Yeah, I’ll try that way which seems to be the best for me too!

Thanks :slight_smile:

simLC | 2019-09-05 12:51