private Vector2 ClosestDot(DOTS dots) { r_pos = g.RedPositions; b_pos = g.BluePositions; List <Vector2> v_pos = dots == DOTS.RED ? r_pos : b_pos; Vector2 closest = new Vector2(0f, 0f); float hyp = 999.0f; int x_left, x_right, y_top, y_bottom; float length, height; bool type; //float angle = 0.0f; foreach (Vector2 pos in v_pos) { F_Setup(pos, out x_left, out x_right, out y_top, out y_bottom, out length, out height, out type); float hyp_tmp = (float)Math.Sqrt(Math.Pow(length, 2) + Math.Pow(height, 2)); if (hyp_tmp < hyp) { hyp = hyp_tmp; closest = pos; //AngleDot(pos, out angle); } } return(closest); }
private void DrawLines(DOTS dots) { List <Vector2> v_pos = dots == DOTS.RED ? r_pos : b_pos; int x_left, x_right, y_top, y_bottom; float length, height; bool type; foreach (Vector2 pos in v_pos) { F_Setup(pos, out x_left, out x_right, out y_top, out y_bottom, out length, out height, out type); float scale = length != 0f ? (float)(height / length) : -1f; int adder = 10; float y = 0f; int xb = x_right - x_left, x = 0; for (int xa = 0; xa < x_right - x_left; xa += adder) { x = type ? xa : xb; y = (float)(x * scale); Vector2 v = new Vector2((float)xa + x_left, (float)y + y_top); if (pos.X == vec_closest_r.X && pos.Y == vec_closest_r.Y) { line_closest.Add(v); } else { lines.Add(v); } xb -= adder; } } }
private void Randomize(int old_x, int old_y, DOTS d) { Random r = new Random(); int x_n = r.Next(0, Width); int y_n = r.Next(0, Height); ground[y_n, x_n] = d == DOTS.RED ? "r" : "b"; ground[old_y, old_x] = "g"; }