static bool RayIntersectDiagonal(Point pivot, Point pointOnRay, Diagonal diagonal) {
     Point a = diagonal.Start;
     Point b = diagonal.End;
     return Point.GetTriangleOrientation(pivot, a, b) == TriangleOrientation.Counterclockwise
         &&
         Point.GetTriangleOrientation(pivot, pointOnRay, a) != TriangleOrientation.Counterclockwise
         &&
         Point.GetTriangleOrientation(pivot, pointOnRay, b) != TriangleOrientation.Clockwise;
 }
        private static void MarkDiagonalAsActiveInTangents(Diagonal diagonal) {
            diagonal.LeftTangent.Diagonal = diagonal;
            diagonal.RightTangent.Diagonal = diagonal;

        }
 private void InsertActiveDiagonal(Diagonal diagonal) {
     diagonal.RbNode = activeDiagonalTree.Insert(diagonal);
     MarkDiagonalAsActiveInTangents(diagonal);
 }
 private void RemoveDiagonalFromActiveNodes(Diagonal diag) {
     RBNode<Diagonal> changedNode = activeDiagonalTree.DeleteSubtree(diag.RbNode);
     if (changedNode != null)
         if (changedNode.Item != null)
             changedNode.Item.RbNode = changedNode;
     diag.LeftTangent.Diagonal = null;
     diag.RightTangent.Diagonal = null;
 }
 private static void MarkDiagonalAsActiveInTangents(Diagonal diagonal)
 {
     diagonal.LeftTangent.Diagonal  = diagonal;
     diagonal.RightTangent.Diagonal = diagonal;
 }
 private void InsertActiveDiagonal(Diagonal diagonal)
 {
     diagonal.RbNode = activeDiagonalTree.Insert(diagonal);
     MarkDiagonalAsActiveInTangents(diagonal);
 }