static bool RunCaptureTest(int centerX, int centerZ, int range, Asteroid[] ast, SpatialPartitionPattern.VisibilityGrid partition) { Vector3 center = new Vector3(-100, 0, -100); int dist = 1200; List <SpaceObject> myList = partition.GetAll((int)center.x, (int)center.z, dist); /* Console.WriteLine("printing close asteroids"); * Console.WriteLine("num close by partition is: {0}", myList.Count);*/ foreach (var t in myList) { if (Vector3.DistanceSquared(center, t.position) < dist * dist) { // Console.WriteLine("valid vector"); } else { // Console.WriteLine("**** invalid vector ****"); } } int countAsteroids = GetNumAsteroidsClose(ast, (int)center.x, (int)center.z, dist); // Console.WriteLine("num close by dist is: {0}", countAsteroids); if (countAsteroids == myList.Count) { return(true); } return(false); }
static bool RunDeleteTest1(int centerX, int centerZ, int range, Asteroid[] ast, SpatialPartitionPattern.VisibilityGrid partition) { partition.ClearAll(); partition.Add(ast[0].spaceObject); Asteroid astDup = ast[0].Duplicate(); partition.Add(astDup.spaceObject); Vector3 center = ast[0].spaceObject.position; int dist = 500; List <SpaceObject> myList = partition.GetAll((int)center.x, (int)center.z, dist); int countToFind = 2; foreach (var obj in myList) { if (obj == ast[0].spaceObject) { countToFind--; } else if (obj == astDup.spaceObject) { countToFind--; } } if (countToFind != 0) { Console.WriteLine("RunDeleteTest1:: invalid storage of vectors ****"); } partition.Remove(astDup.spaceObject); List <SpaceObject> myList2 = partition.GetAll((int)center.x, (int)center.z, dist); if (myList2.Count != myList.Count - 1) { Console.WriteLine("RunDeleteTest1:: wrong number of items deleted"); } else { Console.WriteLine("RunDeleteTest1:: SUCCESS"); return(true); } return(false); }