smallbasic / SmallBASIC

SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for everyday calculations, scripts and prototypes. SmallBASIC includes trigonometric, matrices and algebra functions, a built in IDE, a powerful string library, system, sound, and graphic commands along with structured programming syntax
https://smallbasic.github.io
GNU General Public License v3.0
210 stars 37 forks source link

Wrong angles. #117

Closed H1N1-dev closed 3 years ago

H1N1-dev commented 3 years ago

Angles wrong there. ATAN2() thinks that 0 degrees in down side of screen. But, ARC function thinks that 0 degrees is right side.

'Bug? color rgbf(0.3, 0.3, 0.3) ' Color the axes

line xmax/2, 0, xmax/2, ymax line 0, ymax/2, xmax, ymax/2

color rgbf(1, 0, 0) arc xmax/2, ymax/2, 200, 0, 0.1 ' 0 degrees.

' Zero angle its right side, yes? ang = atan2(10, 0) ' X=10, Y=0. Right side?

print deg(ang) 'No! Right is 90 degrees? ... Also, atan2() range of output is -180 ~ 180, and ARC range of angle is 0 ~ 360. But why?

jsalai49 commented 3 years ago

Well, computers don't think at all :) they do what is written! But sometimes we must just adapt ourselves.... some things here are fantastic (array and string functions), some somewhat less.

I had a problem with atan2() and arc... first the angles go clockwise, as opposite to math, and there are lots of graphic inconsistencies, but we must agree that something revolutionary is hardly expected as it it is in the design. anyway the link below may help you to understand how this works https://smallbasic.github.io/reference/718.html cheers!

H1N1-dev commented 3 years ago

@jsalai49 thanks for help :)

H1N1-dev commented 2 years ago

Now i am learned, atan2() arguments is (y, x), NOT (x, y) And, atan2(5, 0) means Y=5 and X=0. This is standard function implementation in most programming languages.