Created
February 5, 2015 16:11
-
-
Save rutcreate/efc38a52ba98bec13e6b to your computer and use it in GitHub Desktop.
Random point on Disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPointOnDisk(radius) { | |
| var a = Math.random(), | |
| b = Math.random(); | |
| if (b < a) { | |
| c = b; | |
| b = a; | |
| a = c; | |
| } | |
| return { | |
| x: b * radius * Math.cos( 2 * Math.PI * a / b ), | |
| y: b * radius * Math.sin( 2 * Math.PI * a / b ) | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment