Hello, I have a List<Line>. I want to sort the lines by their angles with the X axis in descending order.Some lines'angle with the X axis are in range [0,90), and all the other lines' angle are in range [270,360). But I want the Lines in [0,90) to be in the front part and in descending order,the [270,360) should be in the back part and in descending order. Here is all I can do:
public int sortLinesByAngle(Line a, Line b)
{
if (a.StartPoint.GetVectorTo(a.EndPoint).GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate()) ==
b.StartPoint.GetVectorTo(b.EndPoint).GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate()))
{
//return a.StartPoint.Y.CompareTo(b.StartPoint.Y);
return a.StartPoint.X.CompareTo(b.StartPoint.X);
}
return b.StartPoint.GetVectorTo(b.EndPoint).GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate()).CompareTo(
a.StartPoint.GetVectorTo(a.EndPoint).GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate()));
}
LinesList.Sort(sortLinesByAngle);
But it does not work!!! Anything wrong? How to change?