//get the radius line perpendicular to the tangent at ptTo public void get_RTo(StraightLine rTo) { StraightLine TangTo = new StraightLine(); GetTangTo(TangTo); //zhang revised if (TangTo.bVerticalLine == false) { if (TangTo.k == 0) { rTo.xIntercept = ptTo.X; rTo.bVerticalLine = true; } else { rTo.k = -1 / TangTo.k; rTo.b = ptTo.Y + ptTo.X / TangTo.k; rTo.bVerticalLine = false; } } else//true { rTo.k = 0; rTo.b = ptTo.Y; rTo.bVerticalLine = false; } }
public static String GetPointIntersection(StraightLine line1, StraightLine line2, IPoint PI) { if (line1.bVerticalLine == false && line2.bVerticalLine == false) { PI.X = (line2.b - line1.b) / (line1.k - line2.k); PI.Y = line1.k * PI.X + line1.b; return(null); } else if (line1.bVerticalLine == false && line2.bVerticalLine == true) { PI.X = line2.b; PI.Y = line1.k * line2.b + line1.b; return(null); } else if (line1.bVerticalLine == true && line2.bVerticalLine == false) { PI.X = line1.b; PI.Y = line2.k * line1.b + line2.b; return(null); } else if (line1.bVerticalLine == true && line2.bVerticalLine == true) { //int i = 0; return("Bad Roadway Network!"); //MessageBox.Show("Bad Roadway Network!"); } else { return(null); } }
//Internal methods //get the radius line perpendicular to the tangent at ptFrom public void get_RFrom(StraightLine rFrom) { StraightLine TangFrom = new StraightLine(); GetTangFrom(TangFrom); if (TangFrom.bVerticalLine == false) { if (TangFrom.k == 0) { rFrom.bVerticalLine = true; rFrom.xIntercept = ptFrom.X; } else { rFrom.bVerticalLine = false; rFrom.k = -1 / TangFrom.k; rFrom.b = ptFrom.Y + ptFrom.X / TangFrom.k; } } else { rFrom.k = 0; rFrom.b = ptFrom.Y; rFrom.bVerticalLine = false; } }
//point of intersection public void GetPI(IPoint PI) { StraightLine TangFrom = new StraightLine(); GetTangFrom(TangFrom); StraightLine TangTo = new StraightLine(); GetTangTo(TangTo); StraightLine.GetPointIntersection(TangFrom, TangTo, PI); }
//the tangent line at ptTo public void GetTangTo(StraightLine tangTo) { StraightLine slTemp = new StraightLine(ptAfterTo, ptTo); if (slTemp.bVerticalLine == false) { tangTo.k = slTemp.k; tangTo.b = slTemp.b; } else { tangTo.xIntercept = slTemp.xIntercept; } }
//Center Point public void GetCenterPT(IPoint ptCenter) { //debug zli if (lCurveID == 27) { //int i = 0; } StraightLine rFrom = new StraightLine(); StraightLine rTo = new StraightLine(); get_RFrom(rFrom); get_RTo(rTo); StraightLine.GetPointIntersection(rFrom, rTo, ptCenter); }
//Public Methods //the tangent line at ptFrom public void GetTangFrom(StraightLine tangFrom) { StraightLine slTemp = new StraightLine(ptBeforeFrom, ptFrom); //zhang revised if (slTemp.bVerticalLine == false) { tangFrom.k = slTemp.k; tangFrom.b = slTemp.b; } else { tangFrom.xIntercept = slTemp.xIntercept; } }