I tried to look around for a solution for this kind of a problem, but I was not able to find one. Hence I thought of asking.
PROBLEM:
I have a center and I would like to find a point on the circumference of the circle. Now the constraint is, I would like to be near the “Players position”. The players position could be anywhere from the center and always would be less than the radius ‘r’ from the center. Now as I said ‘near’, I would like to brief that a bit. Lets dividend a circle into quads. If the player lies at 1st Quad then any point on the circumference except 3rd quad is good.
I hope I was clear.
The image representation of the problem is here.
ILLUSTRATION OF THE IMAGE :
Considering the above diagram, lets say the radius of the circle is ‘r’ and the player lies at ‘Pl’. Now just being random, I would like to get a Vector2 co-ordinates anywhere near ‘x’ (red in color). Again here, they are highly arbitrary but they are within the adjacent quads. The required co-ordinates are a vector2 co-ordinates.
THANK YOU very much!!!
regards,
Karsnen
In polar-coordinates you just have to calculate a random angle in the considered area (due to position of the player)
For example position of the player is somethin like (R,theta) in polar-coordinates you could generate a random value for the angle of your searched position between
-piandpiand add it to angle theta of the position of the player.Or if you really want to do this just according to those “quads”: If player is in 1st quad calculate a random value between
-pi/2andpi, if player is in 2nd quad, calculate a random value between0and3pi/2and so on..After this you just have to convert into cartesian coordinates.