Loxy getLoxy(double UpDown, ref Base Base) { Loxy Result = new Loxy(); if ((Curvextruders != null) && (Curvextruders.Count > 0) && (Curvextruders[0].Count > 3)) { xyzArray A = new xyzArray(); for (int j = 0; j < Curvextruders[0].Count; j++) { A.Add(Curvextruders[0][j].Value(0, UpDown)); } xyz N = A.normal(); Base = Base.DoComplete(Curvextruders[0][0].Value(0, UpDown), N); for (int i = 0; i < Curvextruders.Count; i++) { xyArray _A = new xyArray(); Result.Add(_A); for (int j = 0; j < Curvextruders[i].Count; j++) { xy P = Base.Relativ(Curvextruders[i][j].Value(0, UpDown)).toXY(); _A.Add(P); } if (_A.Count > 0) { _A.Add(_A[0]); } } } return(Result); }
/// <summary> /// Overrides the <see cref="Surface.ProjectPoint"/> method and calculates a near point on the cylinder. /// </summary> /// <param name="Point">The u and v relative to the cylinder parameters of a near point.</param> /// <returns></returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); xy Result = new xy(Math.Atan2(p.y, p.x) / UFactor, p.z / Height); return(Result); }
/// <summary> /// gets a circle withe the two points A and B as end and startpoint with a orientation and /// keeps the center. /// </summary> /// <param name="_A">Start point</param> /// <param name="_B">End point</param> /// <param name="ClockWise">sense of the circle</param> public virtual void SetBorder(xyz _A, xyz _B, bool ClockWise) { double ra = aRadius; double rb = bRadius; Arc = new Arc(Center.toXY(), Radius, Arc.getAngle(Base.Relativ(_A).toXY()), Arc.getAngle(Base.Relativ(_B).toXY()), ClockWise); aRadius = ra; bRadius = rb; }
/// <summary> /// overrides this method and calculates a point on the cone in u, v parameters. This point is /// nearest to the given <b>Point</b>. /// </summary> /// <param name="Point"> specifies a 3D-Points, for which a near point on the cone will be calculated and /// whose u and v value will be returned.</param> /// <returns>Resturns the u and v parameter of a near point on the Cone</returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); double u1 = System.Math.Atan2(p.y, p.x); Double v = p.z; xyz Test = Value(u1 / UFactor, v / VFactor); if (Test.dist(Point) > 0.05) { } return(new xy(u1 / UFactor, v / VFactor)); }
/// <summary> /// overrides <see cref="Surface.ProjectPoint(xyz)"/> /// </summary> /// <param name="Point">u and v parameters for <see cref="Surface.Value(double, double)"/>.</param> /// <returns></returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); double u = ((System.Math.Atan2(p.Y, p.x)) - 0.5 * System.Math.PI) / UFactor; double v = System.Math.Atan2(System.Math.Sqrt(p.x * p.x + p.y * p.y), -p.z) / VFactor; if (u < 0) { u = u + 1; } return(new xy(u, v)); }
void xyzHandler(object sender, LineType ViewLine, xyz Point) { if (Device == null) { return; } LineType LT = new LineType(Device.Currentxyz, Device.getProjectionBase().BaseZ); Plane B = new Plane(Base.BaseO, Base.BaseZ); double Lam = -1; xyz PT = new xyz(0, 0, 0); B.Cross(LT, out Lam, out PT); PT = Base.Relativ(PT); }
/// <summary> /// restricted the <see cref="Loxyz"/> to a <see cref="Loxy"/> by omitting the z-value. /// </summary> /// <returns>a <see cref="Loxy"/></returns> public Loxy ToLoxy() { Loxy result = new Loxy(); for (int i = 0; i < Count; i++) { xyArray A = new xyArray(this[i].Count); for (int j = 0; j < A.Count; j++) { A[j] = Base.Relativ(this[i][j]).toXY(); } result.Add(A); } 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> /// is a constructor wich has four points A, B, C, D on the plane and a normalvector N00 /// </summary> /// <param name="A">Point in the plane.</param> /// <param name="B">Point in the plane.</param> /// <param name="C">Point in the plane.</param> /// <param name="D">Point in the plane.</param> /// <param name="N00">Normalvector of the plane.</param> public SmoothPlane(xyz A, xyz B, xyz C, xyz D, xyz N00) : this() { plane = true; Base = Base.From4Points(A, B, C, D); this.N00 = N00.normalized(); this.A00 = Base.Relativ(A).toXY(); this.A10 = Base.Relativ(B).toXY(); this.A01 = Base.Relativ(C).toXY(); this.A11 = Base.Relativ(D).toXY(); this.A = A.toXYZF(); this.B = B.toXYZF(); this.C = C.toXYZF(); this.D = D.toXYZF(); }
void RefreshStartAngle() { xyz A = Base.Relativ(Value(0, 0)); if (Math.Abs(A.x) > 0.00001) { if (Value(0, 0).x > 0) { StartAngle = 0; } else { StartAngle = Math.PI; } } else { A = Base.Relativ(Value(0.5, 0)); if (Math.Abs(A.x) > 0.00001) { if (Value(0.5, 0).x > 0) { StartAngle = 0; } else { StartAngle = Math.PI; } } else { A = Base.Relativ(Value(1, 0)); if (Math.Abs(A.x) > 0.00001) { if (Value(1, 0).x > 0) { StartAngle = 0; } else { StartAngle = Math.PI; } } } } }
/// <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> /// Overrides the method <see cref="Surface.getCross"/> and implements a method for get the crosspoint with a Line <b>L</b>, which is /// nearer to L.Q. /// </summary> /// <param name="L">The line, which will be crossed with the sphere</param> /// <param name="u">gets the u parameter of the cross point</param> /// <param name="v">gets the v parameter of the cross point</param> /// <returns>false if there is no cross point.</returns> public override bool getCross(LineType L, ref double u, ref double v) { xyz Direction = L.Direction.normalized(); xyz P = Base.Relativ(L.P); xyz NDirection = ((Direction & P) & (Direction)); double bb = NDirection.length(); xyz S = new xyz(0, 0, 0); if (Radius > bb) { S = NDirection - Direction * System.Math.Sqrt(Radius * Radius - bb * bb); } else { return(false); } xy Param = this.ProjectPoint(Base.Absolut(S)); u = Param.x; v = Param.Y; return(true); }
/// <summary> /// gets the nearest point on the torus and return this as (u,v) parameters. /// </summary> /// <param name="Point">Specifies the point for which a nearst point shold be calculated.</param> /// <returns>Returns the (u,v) parameters of the nearest point.</returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); double u = System.Math.Atan2(p.y, p.x); double v = System.Math.Atan2(p.z, p.x * System.Math.Cos(u) + p.y * System.Math.Sin(u) - OuterRadius); if (OuterRadius < InnerRadius) { double u1 = u + Math.PI; double v1 = System.Math.Atan2(p.z, p.x * System.Math.Cos(u1) + p.y * System.Math.Sin(u1) - OuterRadius); xyz Q = Value(u / UFactor, v / VFactor); xyz Q1 = Value(u1 / UFactor, v1 / VFactor); if (Q1.dist(p) < Q.dist(p)) { return(new xy(u1 / UFactor, v1 / VFactor)); } } return(new xy(u / UFactor, v / VFactor)); }
/// <summary> /// Project a 3DPoint to the plane. /// </summary> /// <param name="Point">Specifies the point, which will be projected</param> /// <returns>Returns the u and v parameters of the projected point</returns> public override xy ProjectPoint(xyz Point) { xyz p = Base.Relativ(Point); return(new xy(p.x, p.y)); }
private Box GetMaxBox(Base RelativeBase, xyzf pt) { return(GetMaxBox(RelativeBase.Relativ(new xyz(pt.X, pt.Y, pt.Z)))); }
/// <summary> /// calculates like <see cref="GetMaxBox(xyz)"/> an enveloping box. The Point pt is taken relative to the Base. /// </summary> /// <param name="RelativeBase">Base</param> /// <param name="pt">Point</param> /// <returns>enveloping box</returns> internal Box GetMaxBox(Base RelativeBase, xyz pt) { return(GetMaxBox(RelativeBase.Relativ(pt))); }