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.

Name

### PVector

Examples
```PVector v1, v2;

void setup() {
smooth();
noLoop();
v1 = new PVector(40, 20);
v2 = new PVector(25, 50);
}

void draw() {
ellipse(v1.x, v1.y, 12, 12);
ellipse(v2.x, v2.y, 12, 12);
ellipse(v2.x, v2.y, 24, 24);
}```
Description A class to describe a two or three dimensional vector. This datatype stores two or three variables that are commonly used as a position, velocity, and/or acceleration. Technically, position is a point and velocity and acceleration are vectors, but this is often simplified to consider all three as vectors. For example, if you consider a rectangle moving across the screen, at any given instant it has a position (the object’s location, expressed as a point.), a velocity (the rate at which the object’s position changes per time unit, expressed as a vector), and acceleration (the rate at which the object’s velocity changes per time unit, expressed as a vector). Since vectors represent groupings of values, we cannot simply use traditional addition/multiplication/etc. Instead, we’ll need to do some "vector" math, which is made easy by the methods inside the PVector class.

There are additional methods and other ways to use some of these methods in the developers reference.
Fields
x x component of the vector y component of the vector z component of the vector
Methods
set() Sets the x, y, z component of the vector Gets the x, y, z component of the vector Calculate the magnitude (length) of the vector Adds one vector to another Subtracts one vector from another Multiplies the vector by a scalar Divides the vector by a scalar Calculate the Euclidean distance between two points Calculates the dot product Calculates the cross product Normalizes the vector Limits the magnitude of the vector Calculates the angle between two vectors Return a representation of the vector as an array
Constructor
```PVector()
PVector(x, y)
PVector(x, y, z)```
Parameters
x float: x component float: y component float: z component
Usage Web & Application
Updated on June 14, 2010 12:05:29pm EDT