'How to chose a random point at a certain distance to a reference point
I have point A (pointA = (x1, y1)) and I need to choose a random point B (pointB = (x2, y2)) such that the distance between the A and B is equal to K.
Solution 1:[1]
This is a simple math question.
x2 = x1 - k + 2k*new Random().nextDouble()
Now you can calculate y2.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick Allen |
