-
Notifications
You must be signed in to change notification settings - Fork 3
Vector
Numerical data in GlowScript Blocks comes in two types: vector and number.
A vector consists of three single numbers called components. Each component can be separately edited.
Each component field can be filled with any combination of blocks that results mathematically in a single number.
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.
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.
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.
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.
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.