Division

With the division operator we can already provide a nice example of normalizing a vector.

vecmath> a=[7,24]
vecmath> ma=|a|
vecmath> print ma
1
2
3

The result of the length of the vector is:

ma = [25]
1

We can now normalize by deviding the vector a with its length:

vecmath> an=a/ma
vecmath> print an
1
2

Giving the result:

an = [0.28,0.96]
1

The normalization can off course be done in one step:

vecmath> a=[20,21]
vecmath> an=a/|a|
vecmath> print an
1
2
3

The same methodology can be used to normalize a 3D vector.