-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|553|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Teasy
Created : 21 August 2007
Edited : 21 August 2007
Language : Blitz

Math Routines #1

Collection of handy functions for various purposes such as trigonometry.

- very fast for imprecise trigonometry
Function qSin#( Value% )
Function qCos#( Value% )

- polar & cartesian coordinate conversion routines
Function VectorX# ( Distance# , Angle# )
Function VectorY# ( Distance# , Angle# )
Function VectorDistance# ( X# , Y# )
Function VectorAngle# ( X# , Y# )

- short hand
Function vx# ( d# , a# ) Return Sin ( a ) * d End Function
Function vy# ( d# , a# ) Return Sin ( a - 90 ) * d End Function
Function vd# ( x# , y# ) Return Sqr ( x * x + y * y ) End Function
Function va# ( x# , y# ) Return -ATan2 ( x , y ) + 180 End Function

- quick and imprecise
Function qvx# ( d# , a# ) Return qSin ( a ) * d End Function
Function qvy# ( d# , a# ) Return qSin ( a - 90 ) * d End Function

- Range limiting (overflow)
Function RangeFloat#( Value# , Max#=360 )
Function RangeInt%( Value% , Max%=360 )

- Capping (no overflow)
Function CapFloat#( Value# , Min#,Max# )
Function CapInt%( Value% , Min%,Max% )

- Comparison
Function HighestFloat#( Value1# , Value2# )
Function HighestInt%( Value1% , Value2% )
Function LowestFloat#( Value1# , Value2# )
Function LowestInt%( Value1% , Value2% )

- Step limiting (interleaving)
Function InterleaveInt%( Angle% , RotationInterval%=5,Angles%=360 )

- Angles
Function AngleDifference( CurrentAngle , TargetAngle )
Function InterceptAngle( ex#,ey# , evx#,evy# , px#,py# , pvx#,pvy# , bs# , maxtime=0 )

- Collision
Function PointInRect( px,py , rx,ry , w,h )



 

Comments