Skip to content

Commit ec9286f

Browse files
committed
fixing lerp functions in PVector
1 parent 02c2a6b commit ec9286f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

core/src/processing/core/PVector.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,21 +847,44 @@ public void rotate(float theta) {
847847

848848
/**
849849
* Linear interpolate the vector to another vector
850-
* @param PVector the vector to lerp to
850+
* @param v the vector to lerp to
851851
* @param amt The amt parameter is the amount to interpolate between the two vectors where 1.0 equal to the new vector
852852
* 0.1 is very near the new vector, 0.5 is half-way in between.
853853
*/
854854
public void lerp(PVector v, float amt) {
855855
x = PApplet.lerp(x,v.x,amt);
856856
y = PApplet.lerp(y,v.y,amt);
857+
z = PApplet.lerp(z,v.z,amt);
858+
}
859+
860+
/**
861+
* Linear interpolate between two vectors (returns a new PVector object)
862+
* @param v1 the vector
863+
* @param v2 the vector to lerp to
864+
* @param amt The amt parameter is the amount to interpolate between the two vectors where 1.0 equal to the new vector
865+
* 0.1 is very near the new vector, 0.5 is half-way in between.
866+
* @return the resulting lerped PVector
867+
*/
868+
public static PVector lerp(PVector v1, PVector v2, float amt) {
869+
PVector v = v1.get();
870+
v.lerp(v2, amt);
871+
return v;
857872
}
858873

874+
/**
875+
* Linear interpolate the vector to x,y,z values
876+
* @param x the x component to lerp to
877+
* @param y the y component to lerp to
878+
* @param z the z component to lerp to
879+
* @param amt The amt parameter is the amount to interpolate between the two vectors where 1.0 equal to the new vector
880+
* 0.1 is very near the new vector, 0.5 is half-way in between.
881+
*/
859882
public void lerp(float x, float y, float z, float amt) {
860883
this.x = PApplet.lerp(this.x,x,amt);
861884
this.y = PApplet.lerp(this.y,y,amt);
885+
this.z = PApplet.lerp(this.z,z,amt);
862886
}
863887

864-
865888
/**
866889
* ( begin auto-generated from PVector_angleBetween.xml )
867890
*

0 commit comments

Comments
 (0)