Cyberpunk Keanu
03/06/2020, 10:42 AMTim Malseed
03/06/2020, 10:46 AMTim Malseed
03/06/2020, 10:48 AMTim Malseed
03/06/2020, 10:50 AMfun isPointInCircle(point: Point, circleCenter: Point, radius: Int) : Boolean {
return sqrt((point.x - circleCenter.x).pow(2) + (point.y - circleCenter.y).pow(2)) < radius
}
pedro
03/06/2020, 10:51 AM(0,0)
, and radius is r1 and r2 (r1 is smaller), generate a random value for an angle (0-360 degrees or use radians straight away as usually that’s what the drawing primitives will ask you)and generate a random value for the radius, which has to be between r1 and r2.
Now use simple trigonometry to get the (x, y)
position (x = radius * cos angle; y = radius * sin angle
)