Random Point on a Circle
Posted: Wed Jan 29, 2014 12:02 am
I need a way to get the X and Y coordinates of random point on a circle with an origin of (0,0) and a radius of 420px.
This gets 1/2 of the circle.
This gets 1/2 of the circle.
- Code: Select all
const int sr = 420; // Radius
int sx = sr - rand(sr * 2); // X-coordinate
int sy = sqrt(pow(sr, 2) + pow(sx, 2)); // Y-coordinate