lerp()

Calculates new x, y, and z components that are proportionally the same distance between two vectors.

The amt parameter is the amount to interpolate between the old vector and the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is halfway between, and 1.0 sets all components equal to the new vector's.

The static version of lerp(), as in p5.Vector.lerp(v0, v1, 0.5), returns a new p5.Vector object and doesn't change the original.

예제

구문

lerp(x, y, z, amt)
lerp(v, amt)
lerp(v1, v2, amt, [target])

매개변수

x
Number:

x component.

y
Number:

y component.

z
Number:

z component.

amt
Number:

amount of interpolation between 0.0 (old vector) and 1.0 (new vector). 0.5 is halfway between.

v
p5.Vector:

p5.Vector to lerp toward.

v1
p5.Vector:
v2
p5.Vector:
target
p5.Vector:

The vector to receive the result

Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!

관련 레퍼런스