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

Class

PVector

Name

div()

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, v2;

void setup() {
  noLoop();
  v1 = new PVector(90, 80, 0);
  v2 = new PVector(2, 10, 0); 
}

void draw() {
  ellipse(v1.x, v1.y, 12, 12);
  ellipse(v2.x, v2.y, 12, 12);
  v1.div(v2);
  ellipse(v1.x, v1.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);
}

PVector v1, v2;

void setup() {
  noLoop();
  v1 = new PVector(5, 10, 0);
  v2 = new PVector(15, 8, 0); 
}

void draw() {
  ellipse(v1.x, v1.y, 12, 12);
  ellipse(v2.x, v2.y, 12, 12);
  PVector v3 = PVector.div(v1, v2);
  ellipse(v3.x, v3.y, 24, 24);
}
Description Divides a vector by a scalar or divides one vector by another.

Syntax
.div(n) 
.div(v, n) 
.div(v, n, target) 
.div(v) 
.div(v1, v2) 
.div(v1, v2, target) 
Parameters
n float: the value to divide by
v PVector: any variable of type PVector
n float: the number to divide with the vector
v PVector: any variable of type PVector
n float: the number to divide with the vector
target PVector: PVector to store the result
Returnsvoid or PVector
Updated on December 7, 2012 08:53:45am PST

Creative Commons License