public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } Octant b = (Octant)obj; return(b.range == range && x == b.x && y == b.y && z == b.z); }
/// <summary> /// Reformats octants into something compatible with the algorithm. /// Starting octants in each column must be sorted by range in ascending order. /// </summary> protected void GetFinalOctants(IList <Octant>[][] startingOctants) { Octants = new List <Octant> [Dimensions.x + 2][]; for (int x = 0; x < Octants.Length; x++) { Octants[x] = new List <Octant> [Dimensions.y + 2]; } for (int x = 0; x < Octants.Length; x++) { Octants[x][0] = new List <Octant>(0); Octants[x][Dimensions.y + 1] = new List <Octant>(0); } for (int y = 1; y < Octants[0].Length - 1; y++) { Octants[0][y] = new List <Octant>(0); Octants[Dimensions.x + 1][y] = new List <Octant>(0); } int last, avgCount; Octant current = null; for (int x = 0; x < Dimensions.x; x++) { for (int y = 0; y < Dimensions.y; y++) { if (startingOctants[x][y] != null) { last = int.MinValue; avgCount = 1; Octants[x + 1][y + 1] = new List <Octant>((startingOctants[x][y].Count / 3) + 2); foreach (Octant o in startingOctants[x][y]) { if (last < o.range) { if (avgCount > 1) { current /= avgCount; } current = o; last = current.range; Octants[x + 1][y + 1].Add(current); } else { current += o; avgCount++; } } } else { Octants[x + 1][y + 1] = new List <Octant>(0); } } } }