ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.6 KiB

  1. 10 PRINT "COORDINATE CONVERSION"
  2. 20 PRINT
  3. 30 PRINT " ( 1=CARTESIAN TO POLAR)"
  4. 40 PRINT " (-1=POLAR TO CARTESIAN)"
  5. 50 PRINT " ( 0=END PROGRAM)"
  6. 60 PRINT "WHICH DIRECTION";
  7. 70 INPUT D
  8. 79 REM - END PROGRAM?
  9. 80 IF D=0 THEN 380
  10. 89 REM - DIRECT PROGRAM TO PERFORM PROPER CONVERSION
  11. 90 IF D=-1 THEN 320
  12. 98 REM - CONVERT FROM CARTESIAN COORDINATES TO POLAR COORDINATES
  13. 99 REM - ENTER CARTESIAN COORDINATES (ABSCISSA, ORDINATE)
  14. 100 PRINT "X,Y";
  15. 110 INPUT X,Y
  16. 119 REM - POINT ON Y-AXIS?
  17. 120 IF X=0 THEN 170
  18. 129 REM - POINT ON X-AXIS?
  19. 130 IF Y=0 THEN 260
  20. 139 REM - COMPUTE POLAR COORDINATES, ROUND OFF, PRINT
  21. 140 PRINT "R =";INT(SGN(X)*SQR(X[2+Y[2)*100+.5)/100;",";
  22. 150 PRINT " A =";INT(ATN(Y/X)*180/3.1415927*100+.5)/100
  23. 160 GOTO 60
  24. 169 REM - POINT IS ON Y-AXIS; AT ORIGIN?
  25. 170 IF Y=0 THEN 240
  26. 180 PRINT "R =";ABS(Y);",";
  27. 189 REM - IS POINT ABOVE OR BELOW ORIGIN?
  28. 190 IF Y<0 THEN 220
  29. 200 PRINT " A = 90"
  30. 210 GOTO 60
  31. 220 PRINT " A = 270"
  32. 230 GOTO 60
  33. 239 REM - POINT IS AT ORIGIN
  34. 240 PRINT "R = 0, A = 0"
  35. 250 GOTO 60
  36. 259 REM - POINT IS ON X-AXIS
  37. 260 PRINT "R =";ABS(X);",";
  38. 269 REM - IS POINT TO LEFT OR RIGHT OF ORIGIN?
  39. 270 IF X<0 THEN 300
  40. 280 PRINT " A = 0"
  41. 290 GOTO 60
  42. 300 PRINT " A = 180"
  43. 310 GOTO 60
  44. 318 REM - CONVERT FROM POLAR COORDIATES TO CARTESIAN COORDINATES
  45. 319 REM - ENTER POLAR COORDINATES (MAGNITUDE OF RAY, ANGLE)
  46. 320 PRINT "R,A";
  47. 330 INPUT R,A
  48. 339 REM - CONVERT FROM DEGREES TO RADIANS
  49. 340 M=(A-INT(A/360)*360)*3.1415927/180
  50. 349 REM - CALCULATE CARTESIAN COORDINATES, ROUND OFF, PRINT
  51. 350 PRINT "X =";INT(R*COS(M)*100+.5)/100;",";
  52. 360 PRINT " Y =";INT(R*SIN(M)*100+.5)/100
  53. 370 GOTO 60
  54. 380 END