private bool TooCloseToOtherPoints(Coord coord, Coord[,] grid, float cellSize) { // get the position on the grid Coord gridCoord = SpaceToPoissonGrid(coord, cellSize); // check adjacent squares for (int x = gridCoord.x - 1; x < gridCoord.x + 1; x++) { for (int y = gridCoord.y - 1; y < gridCoord.y + 1; y++) { if (x < 0 || x >= grid.GetLength(0) || y < 0 || y >= grid.GetLength(1)) { continue; } Coord cell = grid [x, y]; if (cell != null) { if (coord.Distance(cell) < minDistBetweenPoints) { return(true); } } } } return(false); }
private void NxtFrm_Click(object sender, EventArgs e) { Frame += 1; Frame = Frame % Data.GetLength(0); TimeReal.Text = "Time : " + Frame; Bitmap Frm = GenerateBitmap(screen.Width, screen.Height, Frame, zoom, Xoffset, Yoffset, Data, LogView.Checked); screen.Image = (Image)Frm; }
// Make sure pool is initialized to proper width/height. static Coord() { int width = POOL.GetLength(0), height = POOL.GetLength(1); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { POOL[i, j] = new Coord(i - 3, j - 3); } } }
public static Bitmap GenerateBitmap(int xd, int yd, int frame, double zoom, double Xo, double Yo, Coord[,] datas, bool lg) { Bitmap Frm = new Bitmap(xd, yd); for (int Part = 0; Part < datas.GetLength(1); Part++) { double xa = (zoom * (datas[frame, Part].X)); int Xaff; double ya = (zoom * (datas[frame, Part].Y)); int Yaff; double za = zoom * datas[frame, Part].Z; double Zaff; if (lg) { double dist = Math.Sqrt(xa * xa + ya * ya); double LogDist = Math.Log10(1.0 + dist); double Teta = Math.Sign(ya) * Math.Acos(xa / dist); Xaff = (int)(LogDist * Math.Cos(Teta) - Xo); Yaff = yd - (int)(LogDist * Math.Sin(Teta) - Yo); Zaff = 1.0 / (1.0 + Math.Exp(za / 10)); } else { Xaff = (int)(xa - Xo); Yaff = yd - (int)(ya - Yo); Zaff = 1.0 / (1.0 + Math.Exp(za)); } if (((Xaff >= 0) && (Xaff < xd)) && ((Yaff >= 0) && (Yaff < yd))) { Frm.SetPixel(Xaff, Yaff, Color.FromArgb((int)(100 + 154.0 * Zaff), 0, 0)); } } return(Frm); }