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.
예제
구문
div(n)
div(x, y, [z])
div(arr)
div(v)
div(x, y, [z])
div(v, n, [target])
div(v0, v1, [target])
div(v0, arr, [target])
매개변수
The number to divide the vector by
number to divide with the x component of the vector.
number to divide with the y component of the vector.
number to divide with the z component of the vector.
array to divide the components of the vector by.
vector to divide the components of the original vector by.
The vector to receive the result