/// <summary> /// the Quadrangle should be convex /// </summary> /// <param name="firstCEdge"></param> /// <param name="intIndex"></param> public static CEdge TriangulateQuadrangle_Delaunay(CEdge firstCEdge) { //the four edges constitutes a counter clockwise loop var secondCEdge = firstCEdge.cedgeNext; var thirdCEdge = secondCEdge.cedgeNext; var fourthCEdge = thirdCEdge.cedgeNext; firstCEdge.JudgeAndSetAxisAngle(); secondCEdge.JudgeAndSetAxisAngle(); thirdCEdge.JudgeAndSetAxisAngle(); fourthCEdge.JudgeAndSetAxisAngle(); CEdge newCEdge1 = new CEdge(firstCEdge.FrCpt, thirdCEdge.FrCpt); CEdge newCEdge2 = new CEdge(firstCEdge.ToCpt, thirdCEdge.ToCpt); newCEdge1.SetAxisAngle(); newCEdge2.SetAxisAngle(); var dblMinAngle1 = GetDividedMinAngle(newCEdge1, firstCEdge, secondCEdge, thirdCEdge, fourthCEdge); var dblMinAngle2 = GetDividedMinAngle(newCEdge2, secondCEdge, thirdCEdge, fourthCEdge, firstCEdge); if (dblMinAngle1 <= dblMinAngle2) { return(newCEdge1); } else { return(newCEdge2); } }
/// <summary> /// /// </summary> /// <param name="cedge"></param> /// <remarks> cpt is a vertex in the CDCEL</remarks> public static CEdge FindSmallerAxisAngleCEdgebyCEdge(CPoint cpt, CEdge cedge, bool blnAllowOverlap = false) { cedge.JudgeAndSetAxisAngle(); var IncidentCEdge = cpt.IncidentCEdge; var CurrentCEdge = IncidentCEdge; //test the first edge (IncidentCEdge) if (CurrentCEdge.dblAxisAngle > cedge.dblAxisAngle) { return(CurrentCEdge.GetSmallerAxisAngleCEdge()); } else if (CurrentCEdge.dblAxisAngle < cedge.dblAxisAngle) { CurrentCEdge = CurrentCEdge.GetLargerAxisAngleCEdge(); } else { if (blnAllowOverlap == true) { return(CurrentCEdge); } else { throw new ArgumentException("edges overlap each other."); } } //test other edges (IncidentCEdge) do { //int intCompare = CCmpMethods.Cmp(CurrentCEdge.dblAxisAngle, cedge.dblAxisAngle); //if (intCompare == 1) if (CurrentCEdge.dblAxisAngle > cedge.dblAxisAngle) { return(CurrentCEdge.GetSmallerAxisAngleCEdge()); } else if (CurrentCEdge.dblAxisAngle < cedge.dblAxisAngle) { CurrentCEdge = CurrentCEdge.GetLargerAxisAngleCEdge(); } else { if (blnAllowOverlap == true) { return(CurrentCEdge); } else { throw new ArgumentException("edges overlap each other."); } } } while (CurrentCEdge.GID != IncidentCEdge.GID); //if cedge.dblAxisAngle is larger than the AxisAngles of all the edges, //then the edge with largest AxisAngle is the one we are looking for return(CurrentCEdge.GetSmallerAxisAngleCEdge()); }