This function clamps the vector within the two clamp vectors, and returns the result as a pipe-bar delimited list.
VectorClamp will return a vector within the range set by the clamp arguments.
For example (using the X co-ordinate only for simplicity):
Original Vector is 5
Clamp 1 is 6
Clamp 2 is 7
The result will be 6 (5 is closer to 6 than 7).
When the Original Vector is 8
The result will be 7 (8 is closer to 7 than 6).
VectorClamp([Vector], [Clamp Vector 1], [Clamp Vector 2])
Where:
Vector is a pipe-bar delimited list representing the original vector (X|Y|Z).
Clamp Vector 1 is a pipe-bar delimited list representing the first clamp vector (X|Y|Z).
Clamp Vector 2 is a pipe-bar delimited list representing the second clamp vector (X|Y|Z).
Rule | Result |
---|---|
VectorClamp("5|8","6|6","7|7") | Will return the 2D vector set by the clamp arguments, 6|7. |
VectorClamp("5|8|15","6|6|12","7|7|17") | Will return the 3D vector set by the clamp arguments, 6|7|15. |
Due to floating point precision, some calculations may not be as precise as expected.
This can be avoided by following the advice in the topic Info: Floating Point Precision.