So I used the below code to draw a random point (between 0 and 1) from a unit circle . The code outputs 1 point at a time. So, if I want 5 different points I run the code for 5 times. What I want is to draw N different points (lets say about 1000). Is there a way that I can use for the purpose?
public class UniformPoint {
public static void main(String[] args) {
double t = (2 * Math.PI)*Math.random();
double u = Math.random() + Math.random();
double r;
double x, y;
if(u > 1){
r = 2 - u;
}
else{
r = u;
}
x = (r * Math.cos(t));
y = (r * Math.sin(t));
System.out.println("("+x+", "+y+")");
}
}
Aucun commentaire:
Enregistrer un commentaire