Vectors
Five general functions to assist in the creation and manipulation of vectors are built into FISH.
Vector types can be 2-dimensional, or 3-dimensional.
Vector types can be created with the vector
intrinsic (using two or three arguments), or by using (x,y)
or (x,y,z)
syntax.
Component Access
Vector components can be accessed (for get or set) using parenthesis and a single argument of 1, 2, or 3.
They can also be be accessed using the c -> operator and the accessors x
, y
, or z
, either to retreive or assign a single component of the vector.
See Member Access Operator for obtaining components from vector types returned from FISH functions.
Mathematical Operations
The mathematical operators /, *, +, - are allowed between two vectors of the same type. Each of these operates on a component-b`y`-component basis. For example, v1 * v2 returns a vector (v1.x * v2.x, v1.y * v2.y, v1.z * v2.z). The * operator is available between a vector and a number (integer or floating-point). The / operator is also available between a vector and a number.
Please see Arithmetic for a complete table of operator support.
A few useful library functions for vectors are: math.cross
, math.dot
, math.mag
, math.mag2
, or math.unit
.
These are found in the Math Utilities section; and vector
is in the Constructors section.
Iteration
Vectors are an iterable type. This means you can use it as the target of a loop foreach statement (see Loop ForEach) and can be split (see Splitting). Each component is iterated through in order.
Was this helpful? ... | Itasca Software © 2024, Itasca | Updated: Oct 31, 2024 |