View Single Post
Old 09-17-2014, 10:55 AM   #59
Smashed Transistors
Human being with feelings
 
Smashed Transistors's Avatar
 
Join Date: Jul 2014
Location: Là bas les huîtres (FR)
Posts: 424
Default Alternative to atan2

Diamond angle is a fast alternative to atan2.
It is useful for angle comparisons.

Code:
//______________________________________________________________________
//diamond angle 0..4
function diamAngle(x y) (
  y >= 0 ? (
    x >= 0 ?     y / (x + y) : 1 + x / (x - y);
  ) : (
    x < 0  ? 2 + y / (x + y) : 3 + x / (x - y); 
  );
);
__________________
JSFX plugins and synths. See you here and there: SoundCloud, Youtube, Google Play...
Smashed Transistors is offline   Reply With Quote