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 create a new PVector, but transform the values of the PVector on which they are called. These non-static versions perform the same operation, but the former takes another vector as input, while the latter takes three float values. (See the top and bottom examples above, respectively.)


  • // Non-static (lerp on a specific vector)
    PVector current;
    PVector target;
    void setup() {
      current = new PVector(0.0, 0.0);
      target = new PVector(100.0, 100.0);
      current.lerp(target, 0.5);
      println(current);  // Prints "[ 50.0, 50.0, 0.0 ]"
  • // Static (return a new vector)
    PVector start;
    PVector end;
    PVector middle;
    void setup() {
      start = new PVector(0.0, 0.0);
      end = new PVector(100.0, 100.0);
      middle = PVector.lerp(start, end, 0.5);
      println(middle);  // Prints "[ 50.0, 50.0, 0.0 ]"
  • // Non-static (lerp on a specific vector)
    PVector v;
    void setup() {
      v = new PVector(0.0, 0.0);
    void draw() {
      v.lerp(mouseX, mouseY, 0.0, 0.1);
      ellipse(v.x, v.y, 20, 20);


  • .lerp(v, amt)
  • .lerp(v1, v2, amt)
  • .lerp(x, y, z, amt)


  • v(PVector)the vector to lerp to
  • amt(float)The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). 0.1 is very near the old vector; 0.5 is halfway in between.
  • v1(PVector)the vector to start from
  • v2(PVector)the vector to lerp to
  • x(float)the x component to lerp to
  • y(float)the y component to lerp to
  • z(float)the z component to lerp to


  • PVector