|
Post by bluatigro on Apr 26, 2018 13:32:45 GMT
this can be useful
atan2() can have error
''bluatigro 26 apr 2018 ''math module ''needs : ''as global const : ''pi = atn( 1 ) * 4
function rad( deg ) ''from degrees to radians rad = deg * pi / 180 end function
function degrees( r ) ''from radians to degrees degrees = r * 180 / pi end function
sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub
function atan2( x , y ) ''this i am not sure about if y = 0 then if x > 0 then angle = pi / 2 else if x < 0 then angle = 0 - pi / 2 else atan2 = 20 exit function end if end if end if if x < 0 then angle = atn( x / y ) + pi else angle = atn( x / y ) end if if angle < 0-pi then angle = angle + pi * 2 end if if angle > pi then angle = angle - pi * 2 end if atan2 = angle end function
sub nr.swap byref a , byref b h = a a = b b = h end
sub str.swap byref a$ , byref b$ h$ = a$ a$ = b$ b$ = c$ end sub
function rnd.range( low , high ) rnd.range = rnd(0) * ( high - low ) + low end function
function rnd.int( low , high ) rnd.int = int( rnd.range( low , high + 1 ) ) end function
function rnd.normal( mean , d ) rnd.normal = sqr( abs( 2 * log( rnd(0) ) ) _ * cos( rnd(0) * rnd.pi * 2 ) * d + mean end function
function rnd.exp( mean ) rnd.exp = log( rnd(0) ) * mean end function
|
|