问题描述
我的程序正在圆上创建随机点。我想分别将这些点保留在一个数组中。例如,首先我选择一个随机点(例如,让它为p1),然后我将它们顺时针排序并添加到一个数组中。
This my program output example
而且我正在分享我的程序代码,也许你想看看。
public void producePoint()
{
double angle;
PointF org = new PointF(250,250);
float rad = 250;
for (int i = 0; i < Int32.Parse(totalTextBox.Text); i++)
{
points[i] = new Points();
angle = random.Next(0,360);
points[i].name = "P" + i.ToString();
points[i].coordX = (float)(rad * Math.Cos(angle * Math.PI / 180F)) + org.X + area.X+10;
points[i].coordY = (float)(rad * Math.Sin(angle * Math.PI / 180F)) + org.Y + area.Y+10;
}
}
public void DrawLine(string a,string b)
{
Points point1 = new Points();
Points point2 = new Points();
for (int i = 0; i < Int32.Parse(totalTextBox.Text); i++)
{
if (points[i].name == a)
{
point1 = points[i];
}
if (points[i].name == b)
{
point2 = points[i];
}
if (a == b)
{
point1 = point2;
}
}
private void drawL_Click(object sender,EventArgs e)
{
if (firstPointComboBox.SelectedItem == null || secondPointComboBox.SelectedItem == null)
{
MessageBox.Show("Please,choose points");
}
else
{
DrawLine(firstPointComboBox.SelectedItem.ToString(),secondPointComboBox.SelectedItem.ToString());
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)