This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class

PVector

Name

random3D()

Examples
PVector v;

void setup() {
  v = PVector.random3D();
  println(v);
  // May print something like:
  // [ 0.61554617, -0.51195765, 0.599168 ] or 
  // [ -0.4695841, -0.14366731, -0.8711202 ] or 
  // [ 0.6091097, -0.22805278, -0.7595902 ]
}
Description Returns a new 3D unit vector with a random direction. If you pass in this as an argument, it will use the PApplet's random number generator.
Syntax
.random3D()
.random3D(parent)
.random3D(target)
.random3D(target, parent)
Parameters
parent PApplet: current PApplet instance
target PVector: the target vector (if null, a new vector will be created)
ReturnsPVector
Relatedrandom2D()
Updated on January 1, 2021 03:38:09am EST