Name

lerp()

Examples
current = PVector(0.0, 0.0)
target = PVector(100.0, 100.0)
current.lerp(target, 0.5)
print(current)# Prints "[ 50.0, 50.0, 0.0 ]"
start = PVector(0.0, 0.0)
end = PVector(100.0, 100.0)
middle = PVector.lerp(start, end, 0.5)
print(middle)  # Prints "[ 50.0, 50.0, 0.0 ]"
v = PVector(0.0, 0.0)
v.lerp(25, 30, 0, 0.1)
print(v) # Prints "[ 2.5, 3.0, 0.0 ]"
Description Calculates linear interpolation from one vector to another vector. (Just like regular lerp(), but for vectors.)

Note that there is one static version of this method, and two non-static versions. The static version, lerp(v1, v2, amt) is given the two vectors to interpolate and returns a new PVector object. The static version is used by referencing the PVector class directly. (See the middle example above.) The non-static versions, lerp(v, amt) and lerp(x, y, z, amt), do not return a new PVector, but transform the values of the PVector on which they are called. These non-static versions function the same way, but the former takes another vector as input, while the latter takes three float values. (See the top and bottom examples above, respectively.)
Syntax
.lerp(v, amt)
.lerp(v1, v2, amt)
.lerp(x, y, z, amt)
Parameters
vPVector: the vector to lerp to
amtfloat: The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). 0.1 is very near the new vector. 0.5 is halfway in between.
v1PVector: the vector to start from
v2PVector: the vector to lerp to
xfloat: the x component to lerp to
yfloat: the y component to lerp to
zfloat: the z component to lerp to
Related lerp()

Updated on Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.