/// <summary> /// Get a <see cref="CrossList"/>, which contains the crossing points with /// another curve?. The parameter param1 and param2 in <see cref="CrossItem"/> are converted to /// a curve parameter. /// </summary> /// <param name="Curve"></param> /// <returns></returns> public CrossList GetCrossList(Curve Curve) { xyArray xyArray1 = new xyArray(this.Resolution + 1); xyArray xyArray2 = new xyArray(Curve.Resolution + 1); this.ToArray(xyArray1, 0); Curve.ToArray(xyArray2, 0); CrossList Result = xyArray1.getCrossList(xyArray2, true); for (int i = 0; i < Result.Count; i++) { CrossItem C = Result[i]; C.Param1 = C.Param1 / this.Resolution; C.Param2 = C.Param2 / Curve.Resolution; } return(Result); }
/// <summary> /// It`s the same as the overloaded method, but you can set, whether Tangential points /// should be taken or not. /// </summary> /// <param name="value">An other CurveArray</param> /// <param name="TangentialPoints">True, if the tangential points are taken</param> /// <returns>A Crosslist</returns> public CrossList getCrossList(CurveArray value, bool TangentialPoints) { ArrayList L1 = GetConnections(); ArrayList L2 = value.GetConnections(); int StartJ; CrossList CL; CrossList Result = new CrossList(); Result.AllowMultiCross = TangentialPoints;// for instant int AIndex = 0; for (int i = 0; i < L1.Count; i++) { CurveArray CA = (CurveArray)L1[i]; xyArray A = CA.getxyArray(); int BIndex = 0; StartJ = 0; for (int j = StartJ; j < L2.Count; j++) { CurveArray CB = (CurveArray)L2[j]; xyArray B = CB.getxyArray(); CL = A.getCrossList(B, TangentialPoints); for (int k = 0; k < CL.Count; k++) { CrossItem CI = CL[k]; double aID = CA.xyArrayIndexToCurveArrayIndex(CI.Param1); double bID = CB.xyArrayIndexToCurveArrayIndex(CI.Param2); CI.Param1 = (float)AIndex + CA.xyArrayIndexToCurveArrayIndex(CI.Param1); CI.Param2 = (float)BIndex + CB.xyArrayIndexToCurveArrayIndex(CI.Param2); Curve C1 = CA[Utils.trunc(aID)]; Curve C2 = CB[Utils.trunc(bID)]; double Lam = CI.Param1 - Utils.trunc(CI.Param1); double Mue = CI.Param2 - Utils.trunc(CI.Param2); CI.Param1 = IndexOf(C1) + Lam; CI.Param2 = value.IndexOf(C2) + Mue; Mue = CI.Param2 - Utils.trunc(CI.Param2); Lam = CI.Param1 - Utils.trunc(CI.Param1); if (C1.Cross(C2, Lam, Mue, out Lam, out Mue)) { if ((Lam < 0) && ((System.Math.Abs(Lam) < 0.000001))) { Lam = 0; } if (System.Math.Abs(Lam - 1) < 0.00001) { Lam = 0.999999; } CI.Param1 = Utils.trunc(CI.Param1) + Lam; if ((Mue < 0) && ((System.Math.Abs(Mue) < 0.000001))) { Mue = 0; } if (System.Math.Abs(Mue - 1) < 0.00001) { Mue = 0.999999; } CI.Param2 = Utils.trunc(CI.Param2) + Mue; } else { Lam = 0; if (C1.Equals(C2)) { Lam = 1; } } if ((Utils.trunc(CI.Param1) < 0) && (System.Math.Abs(CI.Param1) < 0.00001)) { CI.Param1 = 0; } if ((Utils.trunc(CI.Param2) < 0) && (System.Math.Abs(CI.Param2) < 0.00001)) { CI.Param2 = 0; } //if (((Utils.trunc(System.Math.Round(CI.Param1,3)) !=System.Math.Round(CI.Param1,3))) // || // ((Utils.trunc(System.Math.Round(CI.Param1,3)) !=System.Math.Round(CI.Param1,3)))) Result.Add(CI); } BIndex += CB.Count; } AIndex += CA.Count; } return(Result); }