Example #1
0
        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++;
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// The plane will be initialized by three float points, which are contained in the plane.
        /// </summary>
        /// <param name="A">First point</param>
        /// <param name="B">Second point</param>
        /// <param name="C">Third point</param>
        public Plane(xyzf A, xyzf B, xyzf C)
        {
            P = A.Toxyz();
            xyz U = new xyz(B.x - A.X, B.y - A.y, B.z - A.z);
            xyz V = new xyz(C.x - A.X, C.y - A.y, C.z - A.z);

            NormalUnit = U & V;
            NormalUnit = NormalUnit.normalized();
        }
Example #3
0
        /// <summary>
        /// With this method you can easily calculate a small Box which contains the oldbox ( this) and
        /// the float point pt
        /// </summary>
        /// <param name="pt">Float point, that will be checked</param>
        /// <returns>Returns the small box, containing the point pt</returns>
        public Box GetMaxBox(xyzf pt)
        {
            Box result;

            if (IsEmpty())
            {
                result.Origin = pt.Toxyz();
                result.Size   = xyz.Null;
                return(result);
            }
            result.Origin = Origin;
            result.Size   = Size;
            if (pt.x < Origin.x)
            {
                result.Origin.x = pt.x; result.Size.x = Size.x + (Origin.x - pt.x);
            }
            if (pt.x > Origin.x + Size.x)
            {
                result.Size.x = pt.x - Origin.x;
            }
            if (pt.y < Origin.y)
            {
                result.Origin.y = pt.y; result.Size.y = Size.y + (Origin.y - pt.y);
            }
            if (pt.y > Origin.y + Size.y)
            {
                result.Size.y = pt.y - Origin.y;
            }

            if (pt.z < Origin.z)
            {
                result.Origin.z = pt.z; result.Size.z = Size.z + (Origin.z - pt.z);
            }
            if (pt.z > Origin.z + Size.z)
            {
                result.Size.z = pt.z - Origin.z;
            }
            return(result);
        }
Example #4
0
 void ITriangle.SetC(xyzf value)
 {
     C = value.Toxyz();
 }
Example #5
0
 void ITriangle.SetB(xyzf value)
 {
     B = value.Toxyz();
 }
Example #6
0
 void ITriangle.SetA(xyzf value)
 {
     A = value.Toxyz();
 }