Reference+
Name
div()
Class
PVector
Description
Divides a vector by a scalar. The version of the method that uses a float acts directly on the vector upon which it is called (as in the first example above). The version that receives both a PVector and a float as arguments is a static methods, and returns a new PVector that is the result of the division operation. Both examples above produce the same visual output.
Examples
PVector v; void setup() { noLoop(); v = new PVector(30, 60, 0); } void draw() { ellipse(v.x, v.y, 12, 12); v.div(6); ellipse(v.x, v.y, 24, 24); }
PVector v1; void setup() { noLoop(); v1 = new PVector(30, 60, 0); } void draw() { ellipse(v1.x, v1.y, 12, 12); PVector v2 = PVector.div(v1, 6); ellipse(v2.x, v2.y, 24, 24); }
Syntax
.div(n)
.div(v, n)
.div(v, n, target)
Parameters
n
(float)
the number by which to divide the vectorv
(PVector)
the vector to divide by the scalartarget
(PVector)
PVector in which to store the result
Return
PVector

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.