Skip to content
Hunter Close edited this page Aug 14, 2018 · 10 revisions

Vectors in GlowScript Blocks

Numerical data in GlowScript Blocks comes in two types: vector and number.

Vector block

A vector consists of three single numbers called components. Each component can be separately edited.

zero vector block

Each component field can be filled with any combination of blocks that results mathematically in a single number.

math op inside vec block

Colors of vector and number blocks

Vector blocks are blue, and number blocks are turquoise. They are different colors to help the user keep track of the two different types of data.

Vector operations in the Vector menu

Mathematical operations that are unique to vectors are listed in the Vector menu. Other mathematical operations that can be used with vectors, but which are not unique to vectors, are listed under the Math menu. For example, to add two vectors, use the addition block, which is found in the Math menu.

Special vector operations involving one vector

To perform a special vector operation involving a single vector, grab the single vector operation block, and click on the operation name to see more operations. The block includes a "shadow block" with a zero vector in it because a program with a vector operation without a vector to follow it would result in an error.

single vec op block menu

Special vector operations involving two vectors

To perform a special vector operation involving two vectors, grab the double vector operation block, and click on the operation name to see more operations. The block includes two "shadow blocks" with zero vectors in them because a program with a vector operation without a vector to follow it would result in an error.

double vec op block menu

Operation blocks are colored according to the data they output

Regardless of whether there are one or two inputs into a vector operations block, the color of the main (or left-most block) indicates whether the output of an operation will be a vector or a scalar. In the example below, the result of a dot product of two vectors is a number, so the main block on top is turquoise. The result of a cross product of two vectors is a vector, so the main block on bottom is blue.

colors of dot and cross product

GlowScript help for vector operations