鑑於:角度上的點不均勻間隔
x =原點X +半徑* Cos(角度);
y =原始Y +半徑* Sin(角度);
爲什麼點不能均勻分佈在圓的邊緣?
的圖像的結果的:
class Circle
{
public Vector2 Origin { get; set; }
public float Radius { get; set; }
public List<Vector2> Points { get; set; }
private Texture2D _texture;
public Circle(float radius, Vector2 origin, ContentManager content)
{
Radius = radius;
Origin = origin;
_texture = content.Load<Texture2D>("pixel");
Points = new List<Vector2>();
//i = angle
for (int i = 0; i < 360; i++)
{
float x = origin.X + radius * (float)Math.Cos(i);
float y = origin.Y + radius * (float)Math.Sin(i);
Points.Add(new Vector2(x, y));
}
}
public void Draw(SpriteBatch spriteBatch)
{
for (int i = 0; i < Points.Count; i++)
spriteBatch.Draw(_texture, Points[i], new Rectangle(0, 0, _texture.Width, _texture.Height), Color.Red);
}
}
看到這個問題。 OP有同樣的問題,你有。 http://stackoverflow.com/questions/14598954/finding-points-on-perimeter-of-a-circle/14599469#14599469 – 2013-02-19 14:41:28