Я хотел вставить точку пересечения края где-то на краю, но край мог бы иметь точку пересечения раньше. Поэтому я хотел отсортировать точки пересечения между Edge.Start
до Edge.Finish
(это Point
).Как отсортировать список <T> в результате функции?
для сортировки я использую parametric T
уравнение, функция выглядит следующим образом:
/// <summary>
/// Get the value of T between startPoint and endPoint
/// </summary>
/// <param name="position">The intersection of edge</param>
/// <param name="startPoint">Start point of edge</param>
/// <param name="endPoint">End Point of edge</param>
/// <returns></returns>
public static double calculateT(Point position, Point startPoint, Point endPoint){
return (position.X - startPoint.X)/(startPoint.X - endPoint.X);
}
и некоторые, где в MainWindow.xaml.cs
я получил это:
//there are some another intesection vertices
Node anotherPointer = new Node(); //pointer
//prev is node that points to start point of edge
//cur is node that points to end point of edge
//nodes is new node that wanted to inserted
//collection of intersection
List<Node> nodes = new List<Node>();
nodes.Add(node); //add the new intersection to the list
//grab all intersection between start point until end point
anotherPointer = prev.Next;
while (anotherPointer != cur) {
nodes.Add(anotherPointer);
anotherPointer = anotherPointer.Next;
}
//how to sort nodes?
проблема мне нужно три параметра в вычислить T
пересечения. как правильно подобрать nodes
по функции calculateT
?
Примечание
Вот мой класс узел.
public class Node {
Point info;
Node next;
}
Вы можете просто использовать условие OrderBy (x => здесь), то, которое вы написали выше, или просто передать точку своей функции, например x => calculateT (x.Point, startPoint, endPoint) – Coder1409
no 'OrderBy' функция внутри: 'node' .. (: –
добавить с помощью System.Linq; – Coder1409