Calculates a new heading and magnitude that are between two vectors.
The amt
parameter is the amount to interpolate between the old vector and the new vector. 0.0 keeps the heading and magnitude equal to the old vector's, 0.5 sets them halfway between, and 1.0 sets the heading and magnitude equal to the new vector's.
slerp()
differs from lerp() because it interpolates magnitude. Calling v0.slerp(v1, 0.5)
sets v0
's magnitude to a value halfway between its original magnitude and v1
's. Calling v0.lerp(v1, 0.5)
makes no such guarantee.
The static version of slerp()
, as in p5.Vector.slerp(v0, v1, 0.5)
, returns a new p5.Vector object and doesn't change the original.
Examples
Syntax
slerp(v, amt)
slerp()
slerp(v1, v2, amt, [target])
Parameters
Returns
Related References
textToContours
Returns an array of arrays of points outlining a string of text written using the font.
textToModel
Converts text into a 3D model that can be rendered in WebGL mode.
textToPaths
Returns a flat array of path commands that describe the outlines of a string of text.
textToPoints
Returns an array of points outlining a string of text written using the font.