Пример #1
0
        public Vector3d CalculateNewDirectionForNewtonMethod <T>(double[] t, T BezierPatch1, T BezierPatch2)
            where T : IPatch
        {
            var P1_u = BezierPatch1.GetPointDerivativeU(t[0], t[1]);
            var P1_v = BezierPatch1.GetPointDerivativeV(t[0], t[1]);
            var n1   = Point.CrossProduct(P1_u, P1_v);

            n1.Normalize();

            var P2_u = BezierPatch2.GetPointDerivativeU(t[2], t[3]);
            var P2_v = BezierPatch2.GetPointDerivativeV(t[2], t[3]);
            var n2   = Point.CrossProduct(P2_u, P2_v);

            n2.Normalize();

            return(Vector3d.Normalize(Vector3d.Cross(n1, n2)));
        }
Пример #2
0
        public List <Tuple <Point, Vector3d> > GeneratePointsWithNormalVectorsForMilling(double umin, double umax, double vmin, double vmax, int nu, int nv, double radius)
        {
            double deltaU = (umax - umin) / nu;
            double deltaV = (vmax - vmin) / nv;
            double tempU  = umin;
            double tempV  = vmin;
            List <Tuple <Point, Vector3d> > List = new List <Tuple <Point, Vector3d> >();

            for (int j = 0; j <= nu; j++)
            {
                tempV       = vmin;
                insertIndex = List.Count;

                for (int i = 0; i <= nv; i++)
                {
                    Point    a = GetPoint(tempU, tempV);
                    Vector3d b = Point.CrossProduct(GetPointDerivativeU(tempU, tempV),
                                                    GetPointDerivativeV(tempU, tempV));

                    b.Normalize();
                    b = b * radius;
                    if (changeDirection)
                    {
                        List.Insert(insertIndex, new Tuple <Point, Vector3d>(a, b));
                    }
                    else
                    {
                        List.Add(new Tuple <Point, Vector3d>(a, b));
                    }

                    tempV += deltaV;
                }

                changeDirection = !changeDirection;
                tempU          += deltaU;
            }

            return(List);
        }