随机获取圆内点

System.Random random = new System.Random(1000);
//半径随机 ,弧度随机
public Vector2 GetCirclePoint(int m_Radius)
{
//随机获取弧度
float radin = (float)GetRandomValue(0, 2 * Mathf.PI);
float x = m_Radius * Mathf.Cos(radin);
float y = m_Radius * Mathf.Sin(radin);
Vector2 endPoint = new Vector2(x, y);
return endPoint;
}
public double GetRandomValue(double min,double max)
{
double v = random.NextDouble() * (max - min) + min;
return v;
}

你可能感兴趣的:(Unity)