# How to calculate a curve between two objects with Python

If I had object A located at world position 0,0,0 and an object B at world position 2,2,0, how would I go about calculating a smooth curve along the Z plane of those two objects with Python? Preferably with low resolution, like 3 or 4 steps between the two objects. My aim is to be able to get the coordinates(or nearest) of those points along the curve. Even more ideally, I would like to be able to adjust the height of the curve(anywhere between a flat line and spherical curve).

I’m sure this is possible, I’m just not sure where to go after getting the vector between the two points. Actually, getting the vector initially might not matter. Any help?

The smoothest curve between two points is a straight line ;).

The only additional parameter you gave is “the height of the curve(anywhere between a flat line and spherical curve)”, which is not precise enough for any algorithm.

Anyway - there is no build-in “curve generator/calculator”. You need to implement that by your own with Python. You can look for interpolation, bezier curve, etc.

v2 = target.worldPosition-own.worldPosition

DStep = v2.magnitude/resolution

p1 = v2*(Dstep*1)

p2 = v2*(Dstep*2)

p1.z-= (Zdist*0)

p2.z-= (Zdist*1)

p3.z-= (Zdist*2)

?

something like this?