pastebin - collaborative debugging tool
blankb.kpaste.net RSS


Binary Radians BRAD
Posted by Anonymous on Mon 20th Feb 2017 03:51
raw | new post

  1. void setup()
  2. {
  3.   size(640, 360);
  4.   background(255);
  5.   noLoop();
  6. }
  7.  
  8. void draw()
  9. {
  10.  
  11.   for (int i=-360; i<=362; i++)
  12.   {
  13.     int bradV=angle2BRAD ((float)i);
  14.     float angleV=BRAD2Angle(bradV);
  15.     println("Angle="+i+",BRAD="+bradV+" angle="+nf(angleV,4,2));
  16.    
  17.   }
  18.  
  19. }
  20.  
  21.  
  22. float BRAD2Angle(int theBRAD)
  23. {
  24.   float retV=0.0f;
  25.  
  26.   retV=(360.0f/65535.0f)*theBRAD;
  27.   retV=retV % 360;
  28.  
  29.   return retV;
  30. }
  31.  
  32.  
  33. int angle2BRAD(float theAngle)
  34. {
  35.   int retV=0;
  36.  
  37.   retV=(int)(theAngle/(360.0f/65535.0f));
  38.   retV=retV & 0xFFFF;
  39.  
  40.   return retV;
  41. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at