Quick Question: Points Along a Circle

How come this gives a generally square distribution rather than a distribution of points along a circle outline?

rx[i] = (int)(Math.cos(Math.PI*2*(Math.random()))*150)+300;

ry[i] = (int)(Math.sin(Math.PI*2*(Math.random()))*150)+400;

[317 byte] By [yahwehagapea] at [2007-11-27 10:01:22]
# 1

The coordinates of your point (rx[i],ry[i]) are completely independent of one another.

If you want the point to be constrained to the edge of a circle then you have to ensure that the same angle is used when calculating the coordinates - even if this angle is chosen randomly.

pbrockway2a at 2007-7-13 0:34:32 > top of Java-index,Java Essentials,Java Programming...