/// <summary> /// Restricts the Curve to the startpoint A and the endpoint B. The method works regular only if /// A and B are "close to the curve". /// </summary> /// <param name="_A"></param> /// <param name="_B"></param> public virtual void SetBorder(xyz _A, xyz _B) { double Lam = 0; _FromParam = 0; _toParam = 1; xyzArray A = new xyzArray(Resolution + 1); ToArray(A, 0); A.Distance(_A, 1e10, out Lam); double f = System.Math.Round(Lam / Resolution, 5); A.Distance(_B, 1e10, out Lam); double t = System.Math.Round(Lam / Resolution, 5); if (System.Math.Abs(f - t) < 0.00000000001) { //if (_A.dist(_B) <0.000000001) //{ // t = 1 - f; //} if (Value(0).dist(Value(1)) < 0.00000001) { f = 0.000000000001; } if (this is Nurbs3d) { Nurbs3d BS = this as Nurbs3d; f = BS.Knots[2]; t = BS.Knots[BS.Knots.Length - 3]; } } _FromParam = f; _toParam = t; }
/// <summary> /// Gets the distance to a line. /// </summary> /// <param name="L">A line</param> /// <param name="MaxDist">maximal distance</param> /// <param name="param">Parameter relative to this curve</param> /// <param name="lam">Prameter relative to L</param> /// <returns>The distance</returns> public double Distance(LineType L, double MaxDist, out double param, out double lam) { double result = Utils.big; xyzArray a = new xyzArray(Resolution + 1); this.ToArray(a, 0); double di = a.Distance(L, MaxDist, out param, out lam); if (!Utils.Less(MaxDist, di)) { param = +param / Resolution; result = di; } return(result); }
/// <summary> /// overrides the <see cref="ProjectPoint(xyz)"/> method of <see cref="Surface"/>. /// </summary> /// <param name="Point">Point, wich will be projected th the surface</param> /// <returns>u amd v parameter. A call <b>Point</b></returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); xyz PD = new xyz(0, 0, 0); xyz PU = new xyz(0, 0, 0); double Lam = -1; double Param = -1; DownPlane.Cross(new LineType(p, Direction), out Lam, out PD); UpPlane.Cross(new LineType(p, Direction), out Lam, out PU); xyzArray A = CurveArray; xyz R = StandardBase.Relativ(p); double u = Curve.Arcus(new xy(R.X, R.y)); xy PP11 = Curve.Value(u); if (PP11.dist(new xy(R.X, R.Y)) > 0.5) { } else { } A.Distance(new LineType(p, Direction), 1e10, out Param, out Lam); if (Height < 0) { double v = p.dist(PD) / PU.dist(PD); xyz PP = Value(u, v); return(new xy(u, v)); } else { xy pt = Curve.Value(u); xyz K = StandardBase.BaseX * pt.x + StandardBase.BaseY * pt.y; Plane P = new Plane(Base.BaseO, Base.BaseZ); LineType L = new LineType(K, Direction); xyz pkt = new xyz(0, 0, 0); P.Cross(L, out Lam, out pkt); double v = pkt.dist(p) / Height; xyz PP1 = Value(u, v); return(new xy(u, v)); } }
/// <summary> /// overrides the <see cref="Surface.ProjectPoint(xyz)"/> method. /// </summary> /// <param name="Point">is the point, which will be projected.</param> /// <returns>u and v parameters for <see cref="Surface.Value(double, double)"/>.</returns> public override xy ProjectPoint(xyz Point) { if (StartAngle == -1) { RefreshStartAngle(); } xyz Pt = Base.Relativ(Point); double v = StartAngle - System.Math.Atan2(Pt.y, Pt.x); xyz Q = Matrix.Rotation(new xyz(0, 0, 1), v) * Pt; xyzArray A = Curve.ToxyzArray(); double Lam = -1; A.Distance(Q, 1e10, out Lam); xyz N = Value(Lam / Curve.Resolution, v); return(new xy(Lam / Curve.Resolution, v)); }
/// <summary> /// crosses two triangles <b>t1</b> and <b>t2</b> /// </summary> /// <param name="t1"></param> /// <param name="t2"></param> /// <param name="Lam"></param> /// <param name="Mue"></param> /// <param name="P"></param> /// <param name="Q"></param> /// <returns></returns> public static bool Cross(TriangleF t1, TriangleF t2, out double Lam, out double Mue, out xyz P, out xyz Q) { xyzArray A = new xyzArray(); xyzArray B = new xyzArray(); A.data = new xyz[] { t1.A.Toxyz(), t1.B.Toxyz(), t1.C.Toxyz(), t1.A.Toxyz() }; B.data = new xyz[] { t2.A.Toxyz(), t2.B.Toxyz(), t2.C.Toxyz(), t2.A.Toxyz() }; Lam = -1; Mue = -1; P = new Drawing3d.xyz(0, 0, 0); Q = new Drawing3d.xyz(0, 0, 0); double d = (A.Distance(B, 1e10, out Lam, out Mue)); if (d < 2) { P = A.Value(Lam); Q = B.Value(Mue); return(true); } return(false); }