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 |
mult() |
| Examples |
PVector v;
void setup() {
noLoop();
v = new PVector(5, 10, 0);
}
void draw() {
ellipse(v.x, v.y, 12, 12);
v.mult(6);
ellipse(v.x, v.y, 24, 24);
}
PVector v1;
void setup() {
noLoop();
v1 = new PVector(5, 10, 0);
}
void draw() {
ellipse(v1.x, v1.y, 12, 12);
PVector v2 = PVector.mult(v1, 6);
ellipse(v2.x, v2.y, 24, 24);
}
|
| Description |
Multiplies a vector by a scalar. The version of the method that uses a float acts directly on the vector upon which it is called (as in the first example above), and therefore has no return value. The versions that receive both a PVector and a float as arugments are static methods, and each returns a new PVector that is the result of the multiplication operation. Both examples above produce the same visual output.
|
| Syntax | .mult(n)
.mult(v, n)
.mult(v, n, target) |
| Parameters |
| n |
float: the number to multiply with the vector |
| v |
PVector: the vector to multiply by the scalar |
| target |
PVector: PVector in which to store the result |
|
| Returns | void or PVector |
Updated on May 19, 2014 05:30:03pm PDT