static void Check(Plane P1, TriangleF T, ref int PtCount, xyzf A, xyzf B, ref xyzf Pt1, ref xyzf Pt2) { double Lam = -1; xyz Pt = new xyz(0, 0, 0); if (P1.Cross(new LineType(A.Toxyz(), (B.Toxyz() - A.Toxyz())), out Lam, out Pt)) { xyz N = A.Toxyz() + (B.Toxyz() - A.Toxyz()) * Lam; if ((Lam >= -0.000000001) && (Lam < 1.000000001)) { if (PtCount == 0) { Pt1 = Pt.toXYZF(); PtCount = 1; } else if (PtCount == 1) { if (Pt1.dist(Pt.toXYZF()) > 0.0001) { Pt2 = Pt.toXYZF(); PtCount++; } } } } }
/// <summary> /// crosses the triangle with a line. It returns true if the cross point is inside the triangle. In this case <b>Lam</b> and <b>Point</b> will be calculated. /// You get the cross point <b>Pt</b> by L.Value(Lam). /// </summary> /// <param name="L">is the line</param> /// <param name="Pt">is the cross point</param> /// <param name="Lam">is the parameter. You get the cross point <b>Pt</b> by L.Value(Lam).</param> /// <returns></returns> public bool Cross(LineType L, ref xyzf Pt, ref double Lam) { Plane P1 = new Plane(A, B, C); xyz P = new xyz(0, 0, 0); Lam = -1; if (P1.Cross(L, out Lam, out P)) { xyz PP = L.Value(Lam); Pt = new Drawing3d.xyzf((float)P.x, (float)P.y, (float)P.z); if (Inside(P.toXYZF())) { Pt = P.toXYZF(); return(true); } } return(false); }
/// <summary> /// overrides <see cref="Surface.GetPointAndNormal(double, double, ref xyzf, ref xyzf)"/> /// </summary> /// <param name="x">first parameter.</param> /// <param name="y">second parameter.</param> /// <param name="Point">point on the sphere.</param> /// <param name="Normal">normal vector of the sphere.</param> public override void GetPointAndNormal(double x, double y, ref xyzf Point, ref xyzf Normal) { xyz _Point = Value(x, y); if (!SameSense) { Normal = ((_Point - Base.BaseO).normalized() * (-1)).toXYZF(); } else { Normal = (_Point - Base.BaseO).normalized().toXYZF(); } Point = _Point.toXYZF(); }
/// <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(); }
xyzf ITriangle.GetC() { return(C.toXYZF()); }
xyzf ITriangle.GetB() { return(B.toXYZF()); }
xyzf ITriangle.GetA() { return(A.toXYZF()); }