Vectors and Matrices (Arrays)
In addition to scalars, Templex supports one- and two-dimensional arrays.
One-dimensional arrays can represent vectors (a row or a column), while two-dimensional arrays can represent matrices. Templex provides a number of functions and operators for performing vector and matrix mathematics, such as cross product, inversion, and concatenation.
{pt1_x = 1.0}
{pt1_y = 2.0}
{pt1_z = 3.0}
{pt2_x = 4.0}
{pt2_y = 5.0}
{pt2_z = 6.0}
and
the midpoint can be calculated with the following
formulae:{pt3_x = (pt1_x + pt2_x) / 2}
{pt3_y = (pt1_y + pt2_y) / 2}
{pt3_z = (pt1_z + pt2_z) / 2}
{pt1 = {1.0, 2.0, 3.0} }
{pt2 = {4.0, 5.0, 6.0} }
{pt3 = (pt1 + p2) / 2}
{
pt = {1.0, 2.0}
theta = PI/4
c = cos(theta)
s = sin(theta)
rot = { {c , -s}, {s, c} }
pt1 = pt * rot
pt2 = pt1 * rot
pt3 = pt2 * inverse(rot)
if (pt1 == pt3) echo ("same")
}
The
following is an example of using a string
array:{
filelist = {"file1", "file2", "file3"}
foreach (filename = filelist)
open(filename)
filename
close
endloop
}