PVector





PVector \ Language (API) \ Processing 1.0
























Search processing.org:





Language (A-Z) \ Libraries \ Tools \ Environment \ Compare \ Troubleshooting






Reference for Processing version 1.0+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

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); v2.add(v1); 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 y component of the vector z z component of the vector Methods set() Sets the x, y, z component of the vector get() Gets the x, y, z component of the vector mag() Calculate the magnitude (length) of the vector add() Adds one vector to another sub() Subtracts one vector from another mult() Multiplies the vector by a scalar div() Divides the vector by a scalar dist() Calculate the Euclidean distance between two points dot() Calculates the dot product cross() Calculates the cross product normalize() Normalizes the vector limit() Limits the magnitude of the vector angleBetween() Calculates the angle between two vectors array() Return a representation of the vector as an array Constructor PVector() PVector(x, y) PVector(x, y, z) Parameters x float: x component y float: y component z float: z component Usage Web & Application

Updated on November 28, 2008 02:39:15pm PST












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 normalize
PVector cross
PVector angleBetween
PVector set
PVector?d
PVector cross
PVector dist
PVector copy
PVector div
PVector sub
PVector angleBetween
PVector set
PVector dot
PVector array
PVector dist
PVector get
PVector get
PVector z
PVector y

więcej podobnych podstron