Within mel scripting we also have access to two in-built data
types, a vector and a matrix. These two data types are very
useful for calculating transformations etc when manipulating
scene objects.

Vectors

The vector data type is a 3D vector on which you can perform
all manner of standard geometric operations.

{
// declare a 3D vectorvector $vec = <<5.2, 1.9, 0.3>>;
// print the values. To access the vector
// components, use .x, .y and .zprint($vec.x + " " +
$vec.y + " " +
$vec.z + "\n");
// a *slight* annoyance here in that if we want to assign
// values to individual components, ie x,y,z; We have to
// use a full assignment, since trying to assign a value
// to $vec.x will result in a an error :(
//
$vec = <<$vec.x,$vec.y,10>>;
print($vec.x + " " +
$vec.y + " " +
$vec.z + "\n");
// declare 2 vectorsvector $x=<<1,-0.2,0.4>>, $y=<<0.2,1,0.9>>;
// perform cross product
$z = cross($x, $y);
// print dataprint("cross product ="+
$z.x + " " +
$z.y + " " +
$z.z + "\n");
// perform dot product and printprint("dot product =" + dot($x,$y) + "\n" );
// to determine the length of the vector, use magprint("length= " + mag($x) + "\n");
// calculate some noise using our vectorprint("noise= " + noise($x) + "\n");
}

Matrices

Matrices can be declared of any dimension and essentially form
multi-scripted floating point arrays.