⇐ Index
⇐ Math Utility
RotateTowards(<-startDir <-targetDir <-maxDegrees) ->newDir
A directional vector is defined as a line drawn from the origin (0, 0, 0)
to a coordinate at the xyz values of the vector. This means 4 dimensional vectors are not supported. The magnitude of the vector (distance from origin to point) is ignored.
The startDir vector will be rotated round toward the targetDir by an angle of maxDegrees, although it will land exactly on the target rather than overshoot. If a negative value is used for maxDegrees, the vector will rotate away from targetDir until it is pointing in exactly the opposite direction, then stops.
The resulting vector newDir is normalized, meaning its magnitude will always be exactly 1. Inputting targetDir (1, 1, 1)
and successfully rotating towards it will therefore output (0.5773503, 0.5773503, 0.5773503)
, not (1, 1, 1)
.
RotateTowards(V3(1 0 0) V3(1 1 1) 10) ->vec
⇐ Index