Variables
For now, only floating point values are supported in the VecMath shell. Vector, matrix and quaternion types can be entered with a syntax that is similar to C/C++.
There are only five types of variables in the vecmathtool:
Scalar: This variable is a single float value. This type can also be entered as an array with one element. This is off course perfectly valid because you can see scalars as one dimensional vectors.
2D vector: This variable must be entered as an array with two elements.
Complex number: This type of variable is an array, but the complex part is defined between parentheses.
3D vector: This variable must be entered as an array with three elements.
Quaternion: This type is again an array, but the complex parts have to be defined between parentheses.
Scalar
A scalar is a simple float which can be assigned to a variable with the equals (=) operator. To enter the example type in the code line per line, and press enter for each line. The print command prints out the the contents of a variable.
vecmath> a = 7.0
vecmath> print a
2
The result is :
a = [7.0]
A scalar can also be defined as an array with a single element:
vecmath> b = [9.3]
vecmath> print b
2
The result is :
b = [9.3]
2D Vector
A 2d vector is defined as an array of two floats (or two operations that result in a float). The REPL shell does not make a distinction between points (place vectors) or vectors. The user (you) has to make that distinction theirself:
vecmath> v = [7.0,2.3]
vecmath> print v
2
The result is :
v = [7.0,2.3]
Complex number
A complex number is defined as an array of two floats, but in contrast to the 2D vector, the complex part is defined between two parentheses:
vecmath> c1 = [ 1, (2)];
vecmath> c2 = [ 3, (4)];
vecmath> c = c1.c2
c = [-5,10]
2
3
4
This corresponds to the quaternion: -5 + 10i
3D Vector
A 3d vector is defined as an array of three floats (or two operations that result in a float). Again, the REPL shell does not make a distinction between points (place vectors) or vectors. The user (you) has to make that distinction theirself:
vecmath> v = [7.0,2.3,5.0]
vecmath> print v
2
The result is :
v = [7,2.3,5]
Quaternions
To create a quaternion, the following syntax is used:
vecmath> q1=[1,(2,3,4)]
vecmath> print q1
2
The output is:
vecmath>q1 = [1 ,( 2 , 3 , 4 )]