The inclusion of vector functions, in DriveWorks, is primarily intended to provide more freedom when it comes to controlling the position, rotation and scale of nodes in 3D documents.
The following Vector functions are available from the Rule Builder in DriveWorks:
EulerCombine rotates the first given vector by the second, allowing rotations to be combined.
The absolute value of a number is how far away from zero it is, meaning it will always be nonnegative.
VectorAbs creates a version of the given vector using the absolute value of its components.
The absolute value of "7|-4|0" would be "7|4|0".
VectorAbs can be used to get the length of the specific axis of a vector.
The following rule would return the Z-axis length of the vector "-6|9|-11":
ListGetItem(VectorAbs("-6|9|-11"),3) will result in 11
VectorScale could be used to create an exploded view effect, where node positions scale from a center point using sliders.
VectorAngle calculates the angle in degrees between two vectors.
The angle between "0|1|0" and "1|0|0" is 90°.
Using VectorClamp on the vector "-6|8|2", with "-4|-4|-4" as clamp vector 1 and "4|4|4" as clamp vector 2, results in "-4|4|2".
VectorMultiply performs the pointwise multiplication of two vectors (x.x, y.y, z.z).
"2|7|-9" multiplied by "0|3|5" results in "0|21|-45".
VectorDivide performs the pointwise division of two vectors (x/x, y/y, z/z).
"-9|18|14" divided by "3|6|-7" results in "-3|3|-2".
VectorMultiply could be used to flip the value of the specific axis of a vector.
In order to flip "3|4|8" on the Y-axis, it can be multiplied by "1|-1|1", resulting in "3|-4|8".
A vector has both magnitude and direction, and these two functions are used to obtain these properties individually.
VectorLength gets the length of a vector (losing directional information).
The length of "0|-6|8" is 10.
VectorNormalize gets a unit vector in the same direction as the vector (losing magnitude information).
"0|-6|8" normalized is "0|-0.6|0.8".
VectorNormalize can be used in conjunction with VectorScale to set the length of a vector, by first normalizing the vector and then scaling it (the scaling factor used will be the length of the new vector).
Lerp (a contraction of linear interpolation) is the simplest method of interpolation, and involves finding a value that is some percentage between two given values.
VectorLerp finds the vector that is a given percentage (value between 0 and 1) between two given vectors.
Linearly interpolating between "-5|-2|0" and "3|4|8" with an interpolation weighting amount of 0.5 results in "-1|1|4".
The value of a Slider Control could be used as the interpolation weighting amount used by VectorLerp in the rule for the position of a Node, allowing a user to control the position of the node between two points.
VectorLookAt differs in that it does not use node addresses for either of its inputs, solely using pipe-delimited positions.
The result of using VectorNegate is a vector with the same length but the opposite direction.
Using VectorNegate on the vector "0|-6|8" would produce "0|6|-8".
The length of both of these vectors is 10, but they are facing in opposite directions.
VectorRotateAroundAxis allows for a position vector to be rotated around an axis (defined by two position vectors) by a given number of degrees.
VectorRotateAroundPoint allows for a position vector to be rotated around another position vector by a given XY rotation.
VectorRotateAroundAxis could be used to create a complex hinge mechanism, without the need for a complex node structure.
|Knowledge Base Article Ref:||KB20021401|