Divides a vector's x
, y
, and z
components.
div()
can use separate numbers, as in v.div(1, 2, 3)
, another p5.Vector object, as in v.div(v2)
, or an array of numbers, as in v.div([1, 2, 3])
.
If only one value is provided, as in v.div(2)
, then all the components will be divided by 2. If a value isn't provided for a component, it won't change. For example, v.div(4, 5)
divides v.x
by, v.y
by 5, and v.z
by 1. Calling div()
with no arguments, as in v.div()
, has no effect.
The static version of div()
, as in p5.Vector.div(v, 2)
, returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
div(n)
div(x, y, [z])
div(arr)
div(v)
div()
div(x, y, [z])
div(v, n, [target])
div(v0, v1, [target])
div(v0, arr, [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.