Difference between revisions of "FSOSS 2010/processing.js/vectors"

From CDOT Wiki
Jump to: navigation, search
(Created page with '<b>Vectors</b> <ul> <li>Object with a direction and magnitude (length)</li> <li>Typically represented using coordinates for simplicity</li> <li>Used for storing position, velo…')
 
Line 6: Line 6:
 
  <li>Processing has a built-in <b>PVector</b> object for 2D and 3D</li>
 
  <li>Processing has a built-in <b>PVector</b> object for 2D and 3D</li>
 
</ul>
 
</ul>
 +
 +
<b>Operations</b><br />
 +
<b>Add</b> two vectors by adding their components [3, 3] + [1, 2] = [4, 5]<br />
 +
<b>Scale</b> a vector by multiplying by a scalar value [1,3] * 2 = [2, 6]<br />

Revision as of 22:00, 27 October 2010

Vectors

  • Object with a direction and magnitude (length)
  • Typically represented using coordinates for simplicity
  • Used for storing position, velocity, acceleration, etc.
  • Processing has a built-in PVector object for 2D and 3D

Operations
Add two vectors by adding their components [3, 3] + [1, 2] = [4, 5]
Scale a vector by multiplying by a scalar value [1,3] * 2 = [2, 6]