Next: Matrix routines Up: Vectors and Matrices Previous: Vectors and Matrices   Contents   Index

# Vectors

• veczero - Returns the zero vector, {0 0 0}
```Example:
vmd > veczero
Info) 0 0 0
```

• (C++) vecadd v1 v2 [v3 ... vn] - Returns the vector sum of all the terms.
```Examples:
vmd > vecadd {1 2 3} {4 5 6} {7 8 9} {-11 -11 -11}
Info) 1 4 7
vmd > vecadd {0.1 0.2 0.4 0.8} {1 1 2 3} {3 1 4 1}
Info) 4.1 2.2 6.4 4.8
Info) 9
```

• (C++) vecsub v1 v2 - Returns the vector subtraction of the second term from the first
```Examples:
vmd > vecsub 6 3.2
Info) 2.8
vmd > vecsub {10 9.8 7} {0.1 0 -0.1}
Info) 9.9 9.8 7.1
vmd > vecsub {1 2 3 4 5} {6 7 8 9 10}
Info) -5 -5 -5 -5 -5
```

• (C++) vecscale c v -
• (C++) vecscale v c - Returns the vector of the scalar value c applied to each term of v
```Examples:
vmd > vecscale .2 {1 2 3}
Info) 0.2 0.4 0.6
vmd > vecscale {-5 4 -3 2} -2
Info) 10 -8 6 -4
vmd > vecscale -2 3
Info) -6
```

• vecdot v1 v2 - Returns the scalar dot product of the two vectors
```Examples:
vmd > vecdot {1 -2 3} {4 5 6}
Info) 12
vmd > vecdot {3 4} {3 4}
Info) 25
vmd > vecdot {1 2 3 4 5} {5 4 3 2 1}
Info) 35
vmd > vecdot 3 -2
Info) -6
```

• veccross v1 v2 - Returns the vector cross product of the two vectors.
```Examples:
vmd > veccross {1 0 0} {0 1 0}
Info) 0 0 1
vmd > veccross {2 2 2} {-1 0 0}
Info) 0 -2 2
```

• veclength v - Returns the scalar length of v ()
```Examples:
vmd> veclength 5
Info) 5.0
vmd > veclength {5 12}
Info) 13.0
vmd > veclength {3 4 12}
Info) 13.0
vmd > veclength {1 -2 3 -4}
Info) 5.47723
```

• veclength2 v - Returns the square of the scalar length of v ()
```Examples:
vmd > veclength2 5
Info) 25
vmd > veclength2 {5 12}
Info) 169
vmd > veclength2 {3 4 12}
Info) 169
vmd > veclength2 {1 -2 3 -4}
Info) 30
```

• vecnorm v - Returns the vector of length 1 directed along v
```Examples:
vmd > vecnorm -10
Info) -1.0
vmd > vecnorm {1 1 }
Info) 0.707109 0.707109
vmd > vecnorm {2 -3 1}
Info) 0.534522 -0.801783 0.267261
vmd > vecnorm {2 2 -2 2 -2 -2}
Info) 0.408248 0.408248 -0.408248 0.408248 -0.408248 -0.408248
```

• vecdist v1 v2 - Returns the distance between the two vectors ( )
```Examples:
vmd > vecdist -1.5 5.5
Info) 7.0
vmd > vecdist {0 0 0} {3 4 0}
Info) 5.0
vmd > vecdist {0 1 2 3 4 5 6} {-6 -5 -4 -3 -2 -1 0}
Info) 15.8745
```

• vecinvert v - Returns the additive inverse of v (v).
```Examples:
vmd > vecinvert -11.1
Info) 11.1
vmd > vecinvert {3 -4 5}
Info) -3 4 -5
vmd > vecinvert {0 -1 2 -3}
Info) 0 1 -2 3
```

Next: Matrix routines Up: Vectors and Matrices Previous: Vectors and Matrices   Contents   Index
vmd@ks.uiuc.edu