public void FindCutLinesSinglePointSetTest() { var ret = HamSandwich.FindCutLines(m_points); // 4 faces, but only 1 bouding face should be taken Assert.AreEqual(3, ret.Count); }
/// <summary> /// Finds a number of solutions for the cut problem. Both per type of soldier and for all soldiers. /// /// NOTE: only works if the x coords of all things are all positive or all negative /// </summary> public void FindSolution() { // obtain dual lines for game objects m_archerLines = PointLineDual.Dual(m_archers.Select(x => (Vector2)x.transform.position)).ToList(); m_spearmenLines = PointLineDual.Dual(m_spearmen.Select(x => (Vector2)x.transform.position)).ToList(); m_mageLines = PointLineDual.Dual(m_mages.Select(x => (Vector2)x.transform.position)).ToList(); // add lines together var allLines = m_archerLines.Concat(m_spearmenLines.Concat(m_mageLines)); // calculate bounding box around line intersections with some margin var bBox = BoundingBoxComputer.FromLines(allLines, 10f); // calculate dcel for line inside given bounding box m_archerDcel = new DCEL(m_archerLines, bBox); m_spearmenDcel = new DCEL(m_spearmenLines, bBox); m_mageDcel = new DCEL(m_mageLines, bBox); // find faces in the middle of the lines vertically m_archerFaces = HamSandwich.MiddleFaces(m_archerDcel, m_archerLines); m_spearmenFaces = HamSandwich.MiddleFaces(m_spearmenDcel, m_spearmenLines); m_mageFaces = HamSandwich.MiddleFaces(m_mageDcel, m_mageLines); // obtain cut lines for the dcel middle faces and final possible cutlines m_solution = new DivideSolution(HamSandwich.FindCutlinesInDual(m_archerFaces), HamSandwich.FindCutlinesInDual(m_spearmenFaces), HamSandwich.FindCutlinesInDual(m_mageFaces), HamSandwich.FindCutlinesInDual(m_archerFaces, m_spearmenFaces, m_mageFaces)); // update solution to the drawer m_lineDrawer.Solution = m_solution; }
public void FindCutlinesInDualSingleRegionTest() { var faces = HamSandwich.MiddleFaces(m_dcel, m_lines); var ret = HamSandwich.FindCutlinesInDual(faces); // 4 faces, but only 1 bouding face should be taken Assert.AreEqual(3, ret.Count); }
public void FindCutLinesThreePointSetsTest() { var ret = HamSandwich.FindCutLines(m_points1, m_points2, m_points3); var expX = new FloatInterval(-1, 1); var expY = new FloatInterval(-2, 2); Assert.AreEqual(1, ret.Count); Assert.IsTrue(expX.ContainsEpsilon(ret[0].Slope)); Assert.IsTrue(expY.ContainsEpsilon(ret[0].HeightAtYAxis)); }
public void FindCutlinesInDualThreeRegionsTest() { var faces1 = HamSandwich.MiddleFaces(m_dcel1, m_lines1); var faces2 = HamSandwich.MiddleFaces(m_dcel2, m_lines2); var faces3 = HamSandwich.MiddleFaces(m_dcel3, m_lines3); var ret = HamSandwich.FindCutlinesInDual(faces1, faces2, faces3); var expX = new FloatInterval(-1, 1); var expY = new FloatInterval(-2, 2); Assert.AreEqual(1, ret.Count); Assert.IsTrue(expX.ContainsEpsilon(ret[0].Slope)); Assert.IsTrue(expY.ContainsEpsilon(ret[0].HeightAtYAxis)); }
static void Main(string[] args) { var turkeySandwich = new TurkeySandwich(); turkeySandwich.PrintIngredients(); turkeySandwich.Eat(); Console.WriteLine("-------"); var hamSandwich = new HamSandwich(); hamSandwich.PrintIngredients(); hamSandwich.Eat(); Console.WriteLine("-------"); var garbageSandwich = new GarbageSandwich(); garbageSandwich.PrintIngredients(); garbageSandwich.Eat(); }
static void Main(string[] args) { Console.WriteLine("What type of sandwich do you want?"); var turkeySandWich = new TurkeySandwich(); var hamSandwich = new HamSandwich(); Console.WriteLine("Write 1 for turkey and 2 for ham"); var food = Console.ReadLine(); //Then we can do something with these sandwiches switch (food) { case "1": Console.WriteLine("Turkey sandwich it is!"); turkeySandWich.MakeTheWich(); break; case "2": Console.WriteLine("Ham sandwich it is!"); hamSandwich.MakeTheWich(); break; } Console.ReadKey(); }
public void MiddleFacesTest() { var ret = HamSandwich.MiddleFaces(m_dcel, m_lines); Assert.AreEqual(4, ret.Count); }
private void food_Click(object sender, EventArgs e) { Button buttonClicked = sender as Button; int rowIndex = orderDetails.Rows.Add(); var row = orderDetails.Rows[rowIndex]; IFood food; switch (buttonClicked.Name) { case "French Baguette": food = new FrenchBaguette(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.frenchBaguetteStock -= 1; break; case "Soft Bread": food = new SoftBread(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.softBreadStock -= 1; break; case "Apple Smoothy": food = new AppleSmoothy(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.appleSmoothyStock -= 1; break; case "Coke": food = new Coke(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cokeStock -= 1; break; case "Ham Sandwich": food = new HamSandwich(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.hamSandwichStock -= 1; break; case "Panini": food = new Panini(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.paniniStock -= 1; break; case "Cookie": food = new Cookie(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cookieStock -= 1; break; case "Cheese Cake": food = new CheeseCake(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cheeseCakeStock -= 1; buttonClicked.Text = "Cheese Cake " + stock.cheeseCakeStock; break; } updateTotal(); loadButtonsText(); }