示例#1
0
        protected override void PrepareGrid()
        {
            Cells = new PolarCell[Rows][];
            float rowHeight = 1.0f / Rows;

            Cells[0] = new PolarCell[1] {
                new PolarCell(0, 0)
            };
            Size = 1;

            for (int row = 1; row < Rows; row++)
            {
                float radius             = (float)row / Rows;
                float circumference      = (float)(2 * Math.PI * radius);
                int   previousCount      = Cells[row - 1].Length;
                float estimatedCellWidth = circumference / previousCount;
                float ratio = (float)Math.Round(estimatedCellWidth / rowHeight);
                int   cells = (int)(previousCount * ratio);

                Cells[row] = new PolarCell[cells];
                for (int col = 0; col < cells; col++)
                {
                    Cells[row][col] = new PolarCell(row, col);
                    Size++;
                }
            }
        }
示例#2
0
        protected override void ConfigureCells()
        {
            foreach (PolarCell cell in EachCell())
            {
                int row = cell.Row;
                int col = cell.Column;

                if (row > 0)
                {
                    cell.CW  = this[row, col + 1] as PolarCell;
                    cell.CCW = this[row, col - 1] as PolarCell;

                    int       ratio  = Cells[row].Length / Cells[row - 1].Length;
                    PolarCell parent = Cells[row - 1][col / ratio] as PolarCell;
                    parent.Outward.Add(cell);
                    cell.Inward = parent;
                }
            }
        }