a port of the Processing Visualization Language
Class PVector
Name

dot()

Examples
PVector  v = new PVector(10, 20, 0);
float d = v.dot(60, 80, 0);
println(d);  // Prints "2200.0"

PVector v1, v2;

void setup() {
  size(100, 100);
  v1 = new PVector(20.0, 30.0, 40.0);
  v2 = new PVector(0.0, 0.0, 0.0);
  v2.set(v1);
  println(v2.x);  // Prints "20.0"
  println(v2.y);  // Prints "30.0"
  println(v2.z);  // Prints "40.0"
}

PVector  v1 = new PVector(10, 20, 0);
PVector  v2 = new PVector(60, 80, 0); 
float d = v1.dot(v2);
println(d);  // Prints "2200.0"
Description

Calculates the dot product of two vectors.

Syntax
vec.dot(x,y,z)

vec.dot(v)

Parameters
vec any variable of type PVector
x float: the x component of the vector
y float: the y component of the vector
z float: the z component of the vector
v PVector: the x, y, and z components from a PVector object
Returns float
Usage Web & Application

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub