PVector::add() \ Language (API) \ Processing 1.0
Language (A-Z) \
Libraries \
Tools \
Environment
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
add()
Examples
PVector v1, v2;
void setup() {
smooth();
noLoop();
v1 = new PVector(40, 20, 0);
v2 = new PVector(25, 50, 0);
}
void draw() {
ellipse(v1.x, v1.y, 12, 12);
ellipse(v2.x, v2.y, 12, 12);
v2.add(v1);
ellipse(v2.x, v2.y, 24, 24);
}PVector v;
void setup() {
smooth();
noLoop();
v = new PVector(40, 20, 0);
}
void draw() {
ellipse(v.x, v.y, 12, 12);
ellipse(25, 50, 12, 12);
v.add(25, 50, 0);
ellipse(v.x, v.y, 24, 24);
}PVector v1, v2;
void setup() {
smooth();
noLoop();
v1 = new PVector(40, 20, 0);
v2 = new PVector(25, 50, 0);
}
void draw() {
ellipse(v1.x, v1.y, 12, 12);
ellipse(v2.x, v2.y, 12, 12);
PVector v3 = PVector.add(v1, v2);
ellipse(v3.x, v3.y, 24, 24);
}
Description
Adds x, y, and z components to a vector, adds one vector to another, or adds two independent vectors together. The version of the method that adds two vectors together 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.add(x, y, z)
vec.add(v)
PVector.add(v1, v2)
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 of a PVector object
v1
PVector: the x, y, and z components of a PVector object
v2
PVector: the x, y, and z components of a PVector object
vec
any variable of type PVector
Returns
None or PVector
Usage
Web & Application
Updated on June 14, 2010 12:05:29pm EDT
Processing was initiated by Ben Fry and Casey Reas. It is developed by a small team of volunteers.
© Info \
Site hosted by Media Temple!
Wyszukiwarka
Podobne podstrony:
PVector normalizePVector crossPVector angleBetweenPVector setPVector crossPVector distPVector copyPVector divPVector subPVector angleBetweenPVectorPVector setPVector dotPVector arrayPVector distPVector getPVector getPVector zPVector ywięcej podobnych podstron