Ooops
March 01, 2021, 10:50:46 PM

Author Topic: [bb] Curve Angle by Ice9 [ 1+ years ago ]  (Read 437 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Curve Angle by Ice9 [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Curve Angle
Author : Ice9
Posted : 1+ years ago

Description : 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


Code :
Code: BlitzBasic
  1. Function curveangle#( currentangle#,desiredangle#,curve# )
  2.        
  3.  
  4.         Adist#= Sqr((DesiredAngle#-CurrentAngle#)*(DesiredAngle#-CurrentAngle#))
  5.     If DesiredAngle>CurrentAngle
  6.                 If Adist#>180
  7.                         CurrentAngle=CurrentAngle-(Adist#/curve)
  8.                         If CurrentAngle<-180 Then CurrentAngle=CurrentAngle+360
  9.                 Else
  10.                         Adist#=360-Adist#
  11.                         CurrentAngle=CurrentAngle+(Adist#/curve)
  12.                         If CurrentAngle>180 Then CurrentAngle=CurrentAngle-360
  13.                 EndIf
  14.                
  15.     Else
  16.                 If ADist#>180
  17.                         CurrentAngle=CurrentAngle+(Adist#/curve)
  18.                         If CurrentAngle>180 Then CurrentAngle=CurrentAngle-360
  19.                 Else
  20.                         Adist#=360-Adist#
  21.                         CurrentAngle=CurrentAngle-(Adist#/curve)
  22.                         If CurrentAngle<-180 Then CurrentAngle=CurrentAngle+360
  23.                 EndIf
  24.     EndIf
  25.                        
  26.         Return CurrentAngle
  27.        
  28. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal