private void btn_cutInit_Click(object sender, RoutedEventArgs e) { int t_int; double t_double; node_cnt = int.TryParse(txt_nodeCnt.Text, out t_int) ? t_int : node_cnt; edge_prob = double.TryParse(txt_edgeProb.Text, out t_double) ? t_double : edge_prob; attempts = int.TryParse(txt_attempts.Text, out t_int) ? t_int : attempts; tau = double.TryParse(txt_tau.Text, out t_double) ? t_double : tau; tauM = double.TryParse(txt_tauM.Text, out t_double) ? t_double : tauM; mu = double.TryParse(txt_mu.Text, out t_double) ? t_double : mu; ceil = double.TryParse(txt_ceil.Text, out t_double) ? t_double : ceil; ceilby = int.TryParse(txt_ceilby.Text, out t_int) ? t_int : ceilby; seed = int.TryParse(txt_seed.Text, out t_int) ? t_int : seed; graph = new bool[node_cnt, node_cnt]; points = new Point[node_cnt]; classes = new bool[node_cnt]; double width = mainCanvas.Width; mainCanvas.ClearCanvas(); ExUtility.SetSeed(seed); double prox = 30; List <Vector> disks = new List <Vector>(); while (disks.Count < node_cnt) { disks = ExUtility.PoissonDiskSample(width * 0.8, prox, 30); disks.Shuffle(); prox *= 0.8; } btn_cutStep.IsEnabled = true; btn_cutPreStep.IsEnabled = true; for (int i = 0; i < node_cnt; i++) { for (int j = i + 1; j < node_cnt; j++) { if (ExUtility.rand.NextDouble() > edge_prob) { continue; } graph[i, j] = true; graph[j, i] = true; } points[i] = new Point(width * 0.1 + disks[i].X, width * 0.1 + disks[i].Y); } DrawGraph(false); }
private void btn_collideInit_Click(object sender, RoutedEventArgs e) { SetParameters(); btn_collidePreStep.IsEnabled = true; btn_collideStep.IsEnabled = true; double width = mainCanvas.Width; mainCanvas.ClearCanvas(); ExUtility.SetSeed(col_seed); startPos = new Point[col_cnt]; endPos = new Point[col_cnt]; startVel = new Point[col_cnt]; endVel = new Point[col_cnt]; List <Vector> disks = ExUtility.PoissonDiskSample(width * 0.8, col_dmin + 2, 30); disks.Shuffle(); if (disks.Count < 2 * col_cnt) { return; } int cnt = 0; // x [obj] [time] [x,y,vx,vy] for (int i = 0; i < col_cnt; i++) { startPos[i] = new Point(width * 0.1 + disks[cnt].X, width * 0.1 + disks[cnt].Y); cnt++; endPos[i] = new Point(width * 0.1 + disks[cnt].X, width * 0.1 + disks[cnt].Y); cnt++; startVel[i] = new Point(ExUtility.RandRange(-col_velrng, col_velrng), ExUtility.RandRange(-col_velrng, col_velrng)); endVel[i] = new Point(ExUtility.RandRange(-col_velrng, col_velrng), ExUtility.RandRange(-col_velrng, col_velrng)); Point s1 = startPos[i]; Point e1 = new Point(s1.X + startVel[i].X, s1.Y + startVel[i].Y); Point s2 = endPos[i]; Point e2 = new Point(s2.X + endVel[i].X, s2.Y + endVel[i].Y); mainCanvas.DrawEdges(Colors.ForestGreen, 2, new Tuple <Point, Point>(s1, e1)); mainCanvas.DrawEdges(Colors.Orange, 2, new Tuple <Point, Point>(s2, e2)); mainCanvas.DrawPoints(Colors.ForestGreen, 8, startPos[i]); mainCanvas.DrawPoints(Colors.Orange, 8, endPos[i]); } }