<=[[4rpl:start| Index]] \\ <=[[4rpl:start#math_utility| Math Utility]] ====== RotateTowards ====== RotateTowards(<-startDir <-targetDir <-maxDegrees) ->newDir ===== Description ===== * **startDir**: The directional vector to start at. * **targetDir**: The directional vector to end up at. * **maxDegrees**: The maximum amount of degrees the start direction will rotate towards the target direction. * **newDir**: The new directional vector (normalized). 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)''. ===== Examples ===== RotateTowards(V3(1 0 0) V3(1 1 1) 10) ->vec <=[[4rpl:start| Index]] ~~NOTOC~~