protected internal override xyz Cross(LineType ViewLine) { //if (PolygonMode == PolygonMode.Line) // Path = PrimId; //else // Path = -1; xyArray A = null; if (Path >= 0) { A = PolyPoly[Path]; double Dummy = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy); if (di < 2 * Snapdist) { return(PolyPoly[Path].Value(Lam).toXYZ()); } else { Lam = -1; } } else { for (int i = 0; i < PolyPoly.Count; i++) { A = PolyPoly[i]; double Dummy = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy); if (di <= 2 * Snapdist) { // Path = i; return(PolyPoly[i].Value(Lam).toXYZ()); } //else // Path = -1; } } xyz Result = new xyz(0, 0, 0); double LineLam = -1; new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result); return(Result); }
/// <summary> /// /// This method calculates the distance of a LineType to this Curve only in case, when the distance is /// smaller then MaxDist, otherwise <see cref="Utils.big"/> will be returned. /// You can imagine a cylinders with radius MaxDist around the Curve. If the line goes through the /// "curved" cylinder, then the distance will be calculated and returned. /// </summary> /// <param name="L">Line, which will be checked</param> /// <param name="MaxDist">Maximal distance</param> /// <param name="param">paramter fo the nearest point in the curve</param> /// <returns>distance</returns> public double Distance(LineType L, double MaxDist, out double param) { double lam; double result = Utils.big; xyArray a = new xyArray(Resolution + 1); this.ToArray(a, 0); double di = a.Distance(L, MaxDist, out param, out lam); if (!Utils.Less(MaxDist, di)) { param = this.fromParam + param * toParam / Resolution; result = di; } return(result); }
public override Base GetBase() { Base B = Base.UnitBase; B.BaseO = Point; int id = -1; xyArray A = null; LineType ViewLine = Device.FromScr(Device.MousePos); xyz P = ModelMatrix * ViewLine.P; xyz Q = ModelMatrix * ViewLine.Q; ViewLine = new LineType(P, Q); for (int i = 1; i < Loca.Count; i++) { A = Loca[i].getxyArray(); A = ModelMatrix * A; double Dummy = -1; double di = A.Distance(ViewLine, Snapdist * 8, out Lam, out Dummy); if (di <= Snapdist) { id = i; // break; } } if (id >= 0) { if (id == 1) { } if (Lam >= 0) { double L = Lam; Lam = Loca[id].xyArrayIndexToCurveArrayIndex(Lam); xyz D = Loca[id].Direction(Lam).toXYZ(); B = Base.DoComplete(A.Value(L).toXYZ(), D, new xyz(0, 0, 1) & D); } } else { B = ModelMatrix.toBase(); B.BaseO = Point; } return(B); }
protected internal override xyz Cross(LineType ViewLine) { double Dummy = -1; double di = Poly.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy); if (di <= 2 * Snapdist) { return(Poly.Value(Lam).toXYZ()); } else { Lam = -1; } xyz Result = new xyz(0, 0, 0); double LineLam = -1; new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result); return(Result); }
public override Base GetBase() { Base B = ModelMatrix.toBase();; B.BaseO = Point; int id = -1; for (int i = 0; i < PolyPoly.Count; i++) { xyArray A = PolyPoly[i]; LineType ViewLine = Device.FromScr(Device.MousePos); double Dummy = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy); if (di <= 2 * Snapdist) { id = i; break; } } if (id >= 0) { xyzArray A = ModelMatrix * PolyPoly[id].ToxyzArray(); if (Lam >= 0) { xyz D = ModelMatrix * PolyPoly[id].Direction(Lam).toXYZ() - ModelMatrix * new xyz(0, 0, 0); B = Base.DoComplete(Point, D, new xyz(0, 0, 1) & D); } } else { xyzArray A = ModelMatrix * PolyPoly[0].ToxyzArray(); xyz D = A.cross(); B = Base.DoComplete(Point, D, new xyz(0, 0, 1) & D); } return(B); }
protected internal override xyz Cross(LineType ViewLine) { xyArray A = this.CurveArray.getxyArray(); double Dummy = -1; double _Lam = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out _Lam, out Dummy); if (di <= 2 * Snapdist) { Lam = this.CurveArray.xyArrayIndexToCurveArrayIndex(_Lam); doExchange = true; return(this.CurveArray.Value(Lam).toXYZ()); } else { Lam = -1; } xyz Result = new xyz(0, 0, 0); double LineLam = -1; new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result); return(Result); }
protected internal override xyz Cross(LineType ViewLine) { //if (PolygonMode == PolygonMode.Line) // Path = PrimId; //else // Path = -1; xyArray A = null; if (Path >= 0) { A = Loca[Path].getxyArray(); double Dummy = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out Lam, out Dummy); if (di <= 2 * Snapdist) { Lam = Loca[Path].xyArrayIndexToCurveArrayIndex(Lam); return(Loca[Path].Value(Lam).toXYZ()); } else { Lam = -1; } } else { double Distance = 1e10; double _Lam = -1; for (int i = 0; i < Loca.Count; i++) { A = Loca[i].getxyArray(); double Dummy = -1; double di = A.Distance(ViewLine, 2 * Snapdist, out _Lam, out Dummy); if (di <= 2 * Distance) { Distance = di; Lam = Loca[i].xyArrayIndexToCurveArrayIndex(_Lam); //Path = i; if ((Path >= 0) && (Lam >= 0)) { return(Loca[Path].Value(Lam).toXYZ()); } continue; } else { Lam = -1; } } if (Distance <= Snapdist) { if ((Path >= 0) && (Lam >= 0)) { return(Loca[Path].Value(Lam).toXYZ()); } } } xyz Result = new xyz(0, 0, 0); double LineLam = -1; new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)).Cross(ViewLine, out LineLam, out Result); return(Result); }