Code archives/Miscellaneous/Curve Angle
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Returns a value between the current angle and the desired angle based on the curve value. Use full for adding smooth movements rather than a sudden jerk or turn | |||||
Function curveangle#( currentangle#,desiredangle#,curve# ) Adist#= Sqr((DesiredAngle#-CurrentAngle#)*(DesiredAngle#-CurrentAngle#)) If DesiredAngle>CurrentAngle If Adist#>180 CurrentAngle=CurrentAngle-(Adist#/curve) If CurrentAngle<-180 Then CurrentAngle=CurrentAngle+360 Else Adist#=360-Adist# CurrentAngle=CurrentAngle+(Adist#/curve) If CurrentAngle>180 Then CurrentAngle=CurrentAngle-360 EndIf Else If ADist#>180 CurrentAngle=CurrentAngle+(Adist#/curve) If CurrentAngle>180 Then CurrentAngle=CurrentAngle-360 Else Adist#=360-Adist# CurrentAngle=CurrentAngle-(Adist#/curve) If CurrentAngle<-180 Then CurrentAngle=CurrentAngle+360 EndIf EndIf Return CurrentAngle End Function |
Comments
None.
Code Archives Forum