Reference for Processing version 1.2. 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 | sub() |
||||||||||||||||
Examples | PVector v1, v2; void setup() { smooth(); noLoop(); v1 = new PVector(40, 20, 0); v2 = new PVector(65, 70, 0); } void draw() { ellipse(v1.x, v1.y, 12, 12); ellipse(v2.x, v2.y, 12, 12); v2.sub(v1); ellipse(v2.x, v2.y, 24, 24); } PVector v; void setup() { smooth(); noLoop(); v = new PVector(65, 70, 0); } void draw() { ellipse(v.x, v.y, 12, 12); ellipse(40, 20, 12, 12); v.sub(40, 20, 0); ellipse(v.x, v.y, 24, 24); } PVector v1, v2; void setup() { smooth(); noLoop(); v1 = new PVector(65, 70, 0); v2 = new PVector(40, 20, 0); } void draw() { ellipse(v1.x, v1.y, 12, 12); ellipse(v2.x, v2.y, 12, 12); PVector v3 = PVector.sub(v1, v2); ellipse(v3.x, v3.y, 24, 24); } |
||||||||||||||||
Description | Subtracts x, y, and z components from a vector, subtracts one vector from another, or subtracts two independent vectors. The version of the method that substracts two vectors is a static method and returns a PVector, the others have no return value -- they act directly on the vector. See the examples for more context. | ||||||||||||||||
Syntax | vec.sub(x, y, z) vec.sub(v) PVector.sub(v1, v2) |
||||||||||||||||
Parameters |
|
||||||||||||||||
Returns | None or PVector | ||||||||||||||||
Usage | Web & Application |