在具有特定标题的段上获取圆上的随机点
Get random point on circle on a segment that has a specific heading
我有一个圆,有特定的半径。在圆圈内,我有一个带有 X、Y 坐标的点。我也有一个标题,例如 210。如何在从该点到圆边缘绘制的线段上获得一个随机点 INSIDE THE CIRCLE?谢谢!
double radiusCircle = 10;
double y = -3;
double x = -Math.Sqrt(3 * 9);
double angleRad = Math.Atan2(y, x);
double angleDeg = angleRad * 180 / Math.PI; // 210 (-150) degrees
double distancePointCenter = Math.Sqrt(x * x + y * y);
double distancePointMargin = radiusCircle - distancePointCenter;
Random rand = new Random(123);
for (int i = 0 i < 10; i++)
{ // Generate 10 random points
double randomPointDistToCenter = distancePointCenter + distancePointMargin * rand.NextDouble();
double xRandomPoint = randomPointDistToCenter * Math.Cos(angleRad);
double yRandomPoint = randomPointDistToCenter * Math.Sin(angleRad);
}
我有一个圆,有特定的半径。在圆圈内,我有一个带有 X、Y 坐标的点。我也有一个标题,例如 210。如何在从该点到圆边缘绘制的线段上获得一个随机点 INSIDE THE CIRCLE?谢谢!
double radiusCircle = 10;
double y = -3;
double x = -Math.Sqrt(3 * 9);
double angleRad = Math.Atan2(y, x);
double angleDeg = angleRad * 180 / Math.PI; // 210 (-150) degrees
double distancePointCenter = Math.Sqrt(x * x + y * y);
double distancePointMargin = radiusCircle - distancePointCenter;
Random rand = new Random(123);
for (int i = 0 i < 10; i++)
{ // Generate 10 random points
double randomPointDistToCenter = distancePointCenter + distancePointMargin * rand.NextDouble();
double xRandomPoint = randomPointDistToCenter * Math.Cos(angleRad);
double yRandomPoint = randomPointDistToCenter * Math.Sin(angleRad);
}