# How to Interpolate vectors in Python?

How to interpolate vector between 2 vectors in blender-python? I hope you get my question. Example:

See mathutils.Vector:

1. Vector.lerp for linear interpolation.

2. Vector.slerp for spherical interpolation. https://en.wikipedia.org/wiki/Slerp

c = a.lerp(b, 0.0)
# c == a
c = a.lerp(b, 0.5)
# c == (a + b) / 2
c = a.lerp(b, 1.0)
# c == b

• i think you mean C == B in your third example – StarWeaver Dec 5 '14 at 23:38
from mathutils import Vector

v = Vector((0,1,2))
v.negate()
print(v)
# <Vector (-0.0000, -1.0000, -2.0000)>

def interpolate(t, vector_a, vector_b):
# t is from interval <0, 1>
return (1 - t) * vector_a + t * vector_b