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-53.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:



Position <img src="" /> <img src="" />

The elements (xy) represent a coordinate in 2D space. x represents left and right, and y represents up and down. The elements (xyz) 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.


Direction   <img src="" />

<img src="" /> 2D vector. <img src="" /> 3D vector. The elements (xyz) 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.

Displacement   <img src="" />

<img src="" />

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.

Modifier TilesThere a few tiles under the vector category. I'm going to explain what most of them do.

Normal <img src="" />

<img src="" />

Normal simply takes a vector and makes its length or magnitude 1.

Dot Product <img src="" />

<img src="" />

Dot product returns the angle between two vectors.Example:

Cross Product <img src="" />

<img src="" />

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. The ordering of your tiles does matter. If you were to switch Vector 1 and Vector 2Vector 3 would point down instead.

Vector Rotate

<img src="" />

<img src="" />

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.

Mathematical OperationsEdit

Here are just a few mathematical operations that can be performed on vectors:


<img src="" />

<img src="" />

You can find the halfway point between two direction vectors by adding them together. 

<img src="" />

<img src="" />

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.


<img src="" />

<img src="" />

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.Example:


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. 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.

Isobarycenter (also called centroid in Physics)

<img src="" />

<img src="" />

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.Example:

Ad blocker interference detected!

