DriveWorks Pro 18: VectorClamp [send feedback...]

VectorClamp

This function clamps the vector within the two clamp vectors, and returns the result as a pipe-bar delimited list.

This function can be used to simplify using VectorMin along with VectorMax functions.

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).

Syntax

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).

Examples

RuleResult
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.
Floating Point Precision

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.


Please see How To: Understanding Vector Functions for more information on Vectors, all the Vector functions provided in DriveWorks and use case examples.

Table of Contents