User Tools

Site Tools


4rpl:commands:rotatetowards

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
4rpl:commands:rotatetowards [2021/01/08 11:01] – external edit 127.0.0.14rpl:commands:rotatetowards [2022/09/04 09:28] (current) Karsten75
Line 1: Line 1:
-~~NOTOC~~ +<=[[4rpl:start| Index]] \\ 
-<=[[4rpl:start| Index]]+<=[[4rpl:start#math_utility| Math Utility]] 
  
 ====== RotateTowards ====== ====== RotateTowards ======
-RotateTowards(<-start <-target <-maxDegrees) ->vec+ 
 +RotateTowards(<-startDir <-targetDir <-maxDegrees) ->newDir
  
 ===== Description ===== ===== Description =====
-Rotates a start vector (x,y,z) towards target vector (x,y,z). Will not move more than maxDegrees.  The resulting vector is pushed to the stack as a float of three floats+ 
-Each vector is treated as a direction rather than position and is treated as having 3 values.  So 4 dimensional vectors are not supported. +  * **startDir**: The directional vector to start at. 
-If negative maxDegrees is specified, the result is a vector that rotates away from the target vector.+  * **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 coordinate at the xyz values of the vectorThis 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 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 ===== ===== Examples =====
 +
 <code 4rpl> <code 4rpl>
 RotateTowards(V3(1 0 0) V3(1 1 1) 10) ->vec RotateTowards(V3(1 0 0) V3(1 1 1) 10) ->vec
 </code> </code>
 +
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
 +
 +~~NOTOC~~
  
4rpl/commands/rotatetowards.1610121708.txt.gz · Last modified: 2021/01/08 11:01 by 127.0.0.1