Vectors and points

 This is my guide on vectors and points. What are they, you ask? Well simply put, vectors and points are arrays of real numbers, called their coordinates, like this:   ( 1 ,  -5 ,  3.14 ). Theoretically a vector or a point can have an infinite number of elements, but let's just stick with   2D   and   3D   vectors/points (this is to say, vectors/points with 2 or 3 coordinates). Vectors and points can represent a few different things: 

Point:
Position  

The elements ( x ,  y ) represent a coordinate in 2D space. x  represents left and right, and  y  represents up and down.   The elements ( x ,  y ,  z ) represent a coordinate in 3D space. x  and  z  represent left, right, back, and forward and  y  represents up and down.   2D points are for determining a position on the screen. -1 on the  x  axis is the far left of the screen and 1 is the far right. -1 and 1 on the  y  axis are the bottom and top, respectively, and 0 is the dead center of the screen.

Vector:
Direction  

 2D vector. <img src="http://i.imgur.com/rfsmAS1.gif" /> <span style="font-family: 'trebuchet ms', geneva;">3D vector. <span style="font-family: 'trebuchet ms', geneva;">  <span style="font-family: 'trebuchet ms', geneva;">The elements ( x ,  y ,  z ) represent the head's offset from the tail. The white line represents the direction of the vector, and by default has a length or magnitude of 1.

<span style="font-family: 'trebuchet ms', geneva;"> Displacement <span style="font-family: 'trebuchet ms', geneva;"> <img src="http://i.imgur.com/ivACkTD.jpg" />

<img src="http://i.imgur.com/rNYwsOC.gif" />

<span style="font-family: 'trebuchet ms', geneva;">A velocity vector is similar to a direction vector, the main difference being it stores both direction and velocity. The length or magnitude of the vector determines the velocity and can vary. Notice the length of the vector is 2 when the projectile is fired, and approaches 0 as it reaches the peak of its arch, and then begins to increase again as it is pulled by gravity. Velocity vectors are not particularly useful in Project Spark unless you are handling your own physics.

<span style="font-size: 18pt; color: #808080; font-family: 'trebuchet ms', geneva;">Modifier Tiles <span style="font-family: 'trebuchet ms', geneva;">There a few tiles under the vector category. I'm going to explain what most of them do.

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Normal <img src="http://i.imgur.com/CmDuAuw.jpg" />

<img src="http://i.imgur.com/0zK10kx.gif" />

<span style="font-family: 'trebuchet ms', geneva;">Normal simply takes a vector and makes its length or magnitude 1.

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Dot Product <img src="http://i.imgur.com/4buDdmY.jpg" />

<img src="http://i.imgur.com/ziFuIIa.gif" />

<span style="font-family: 'trebuchet ms', geneva;">Dot product returns the angle between two vectors. <span style="font-family: 'trebuchet ms', geneva;">Example: http://imgur.com/Ha0vL9d

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Cross Product <img src="http://i.imgur.com/bhkFJQe.jpg" />

<img src="http://i.imgur.com/oGZJx5v.gif" />

<span style="font-family: 'trebuchet ms', geneva;">Cross product gives you a vector that is perpendicular to both of the vectors you apply it to. In the example above,  Vector 2  is the cross product of  Vector 1  and World Up. Vector 3  is the cross product of  Vector 1  and  Vector 2. <span style="font-family: 'trebuchet ms', geneva;">  <span style="font-family: 'trebuchet ms', geneva;">The ordering of your tiles does matter. If you were to switch  Vector 1  and  Vector 2 ,  Vector 3  would point down instead.

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Vector Rotate

<img src="http://i.imgur.com/rzxBpKT.jpg" />

<img src="http://i.imgur.com/bX1Ixdb.gif" />

<span style="font-family: 'trebuchet ms', geneva;">Vector rotate rotates a vector at a given angle in degrees. In the example above,  Vector 1  is being rotated 15 degrees with  Vector 2  as the pivot.

<span style="font-size: 18pt; color: #808080; font-family: 'trebuchet ms', geneva;">Mathematical Operations
<span style="font-family: 'trebuchet ms', geneva;">Here are just a few mathematical operations that can be performed on vectors:

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Addition

<img src="http://i.imgur.com/OMnL9kP.jpg" />

<img src="http://i.imgur.com/ixwMcSs.gif" />

<span style="font-family: 'trebuchet ms', geneva;">You can find the halfway point between two direction vectors by adding them together. <span style="font-family: 'trebuchet ms', geneva;">

<img src="http://i.imgur.com/kYaRd4n.jpg" />

<img src="http://i.imgur.com/BHTjyHj.gif" />

<span style="font-family: 'trebuchet ms', geneva;">You can add a vector to a point to move the point along that vector. If you tried to do [Red Sphere][position][=][forward], then the sphere would be floating near world center (0, 0, 0), so it is important to add the vector to the position.

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Subtraction

<img src="http://i.imgur.com/CmDuAuw.jpg" />

<img src="http://i.imgur.com/0zK10kx.gif" />

<span style="font-family: 'trebuchet ms', geneva;">Subtracting your brain object's position from your target object's position will create a displacement vector from you to the target object. The length of that vector will be equal to the distance between the two objects, so you will need to normalize it to get the direction. <span style="font-family: 'trebuchet ms', geneva;">Example: http://i.imgur.com/Ha0vL9d.jpg

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Multiplication

<span style="font-family: 'trebuchet ms', geneva;">Multiplying a vector increases or decreases its length. Multiply it by 2 and it will double its length. Multiply it by 0.5 and it will cut it in half. <span style="font-family: 'trebuchet ms', geneva;">  <span style="font-family: 'trebuchet ms', geneva;">Multiplying a vector by -1 will invert it, causing it to point in the opposite direction. It may be easier however to simply add a [negative] tile in front of the vector tile.

<span style="font-size: 12pt; font-family: 'trebuchet ms', geneva;">Isobarycenter (also called centroid in Physics)

<img src="http://i.imgur.com/SalXaum.jpg" />

<img src="http://i.imgur.com/OFQ8Mig.gif" />

<span style="font-family: 'trebuchet ms', geneva;">You can add positions and divide by the total number of positions you've added to find the midpoint or average position between two or more points. <span style="font-family: 'trebuchet ms', geneva;">Example: http://imgur.com/CXoa7xj