|
Post by igoatm on Feb 14, 2015 23:28:01 GMT 1
Not sure if I am going dappy but whilst working on some matrix math it seems that the returned values for SIN(x) and COS(X) are mixed up ie COS(x) is returning SIN(X) values and SIN(X) is returning COS(X) values
Nop It is just me going dappy mixed my x n y up in ATN2 function
' ATN2() ' Needed as bacon only offers the dule quadrent ATN ' for positive none zero x ' this was built using the wekipida define ' it seems to be the most standadised version ' and is the same define as used by the c complier ' USED WIKIPEDIA DEFINITION ' x > 0 = ATN(y/x) ' y >= 0, x < 0 ATN(y/x)+PI ' y < 0, x < 0 ATN(y/x)-PI ' y > 0, x = 0 +PI/2 ' y < 0, x = 0 -PI/2 ' y = 0, x = 0 "UNDEFINED" FUNCTION ATN2(FLOATING x, FLOATING y) ' -------------------- LOCAL rn TYPE float IF x EQ 0 THEN IF y EQ 0 THEN rn = 0 ELSE IF y LT 0 THEN rn = -PI/2 ELSE rn = PI/2 ENDIF ENDIF ELSE IF x GT 0 THEN rn = ATN(y/x) ELSE IF y GE 0 THEN rn = ATN(y/x)+PI ELSE rn = ATN(y/x)-PI ENDIF ENDIF ENDIF RETURN rn END FUNCTION
|
|
|
Post by vovchik on Feb 15, 2015 0:29:19 GMT 1
Dear igoatm, I was just going to write to tell you that BaCon uses the standard C math functions cos() and sin(), so if there is something wrong there, it would have been picked up decades ago. ' compare BaCon and native C functions PRINT cos(45) PRINT sin(45) PRINT COS(45) PRINT SIN(45)
I am glad you found the bug in your source. You had me worried for a few seconds. With kind regards, vovchik
|
|