static public void Iteration() { if (setToProcess.Count == 0) // Tant qu'il y a des ensembles de point à traiter { return; } Console.WriteLine("Iteration_QuickHull"); Tuple <Tuple <LinkedListNode <V2>, LinkedListNode <V2> >, List <V2> > pairToProcess = setToProcess.First(); // Récupération du coté et des points à traiter. Tuple <LinkedListNode <V2>, LinkedListNode <V2> > pointsMainVector = pairToProcess.Item1; // Récupération des points composant le coté. List <V2> points = pairToProcess.Item2; // Récupération de l'ensemble où peut être le nouveau point V2 furthestPoint = findFurthestPoint(pointsMainVector.Item1.Value, pointsMainVector.Item2.Value, points); // Point le plus éloigner de la droite. LinkedListNode <V2> furtherPointNode = convexHull.AddAfter(pointsMainVector.Item1, furthestPoint); // Ajout du point entre les points délimitant le coté. setToProcess.RemoveFirst(); addSetToSetToPrecess(furtherPointNode, pointsMainVector.Item2, points); // Ajout d'un nouveau set à traiter et coté. addSetToSetToPrecess(pointsMainVector.Item1, furtherPointNode, points); /* Draw */ Affichage.RefreshScreen(); Affichage.DrawSet(SetofPoints.LP, Color.Blue); //Affichage.DrawPolChain(SetofPoints.LP, Color.Green); Affichage.DrawPolChain(convexHull.ToList <V2>(), Color.Red); Affichage.Show(); }
public static void ScenarioTest() { Scenario.GetScenario(LP); // affichage Affichage.RefreshScreen(); Affichage.DrawSet(LP, Color.Blue); Affichage.DrawPolChain(LP, Color.Green); Affichage.Show(); }
public static void RandomTest() { // creation d'une liste de points Scenario.CreateRandomPoint(LP, 30); // affichage Affichage.RefreshScreen(); Affichage.DrawSet(LP, Color.Blue); Affichage.Show(); }
static public void Iteration() { Console.WriteLine("Iteration_MelkMan"); List <V2> points = SetofPoints.LP; if (currentIndex == points.Count) // Verifie s'il reste des points à traiter { return; } int initialSize = convexHull.Count(); // Taille de l'enveloppe avant ajout d'un nouveau point LinkedListNode <V2> first = convexHull.First; LinkedListNode <V2> last = convexHull.Last; V2 leftVector = first.Next.Value - first.Value; // Vecteur à gauche du dernier point V2 rightVector = last.Previous.Value - last.Value; // Vecteur à droite du dernier point bool again = true; while (again && currentIndex != points.Count) // On parcours les points de l'essemble LP tant qu'un point n'a pas été ajouté à l'enveloppe et que tous n'ont pas été parcouru. { Console.WriteLine("CurrentIndex_Iteration"); V2 tempLeftVector = points[currentIndex] - first.Value; // Vecteur à comparer à leftVector V2 tempRightVector = points[currentIndex] - last.Value; // Vecteur à comparer à rightVector BigInteger prodVecLeft = tempLeftVector ^ leftVector; BigInteger prodVecRight = tempRightVector ^ rightVector; if (prodVecLeft < 0 || prodVecRight > 0) { while (prodVecLeft < 0) // Tant que le nouveau point peut être placé à gauche { convexHull.RemoveFirst(); first = convexHull.First; leftVector = first.Value - first.Next.Value; tempLeftVector = first.Value - points[currentIndex]; prodVecLeft = tempLeftVector ^ leftVector; } convexHull.AddFirst(points[currentIndex]); while (prodVecRight > 0) // Tant que le nouveau point peut être placé à droite { convexHull.RemoveLast(); last = convexHull.Last; rightVector = last.Value - last.Previous.Value; tempRightVector = last.Value - points[currentIndex]; prodVecRight = tempRightVector ^ rightVector; } convexHull.AddLast(points[currentIndex]); again = false; } currentIndex++; } /* Draw */ Affichage.RefreshScreen(); Affichage.DrawSet(SetofPoints.LP, Color.Blue); Affichage.DrawPolChain(SetofPoints.LP, Color.Green); Affichage.DrawPolChain(convexHull.ToList <V2>(), Color.Red); Affichage.Show(); }