Ejemplo n.º 1
0
        public static Direction GetNormal(PointUV uv, double p, double q, double circleAngle, Vector inverseOffset, bool isInverted)
        {
            double delta  = 0.001;
            var    deltaU = VectorUV.Create(delta, 0);
            var    deltaV = VectorUV.Create(0, delta);

            PointUV uv00 = uv - deltaU;
            PointUV uv01 = uv + deltaU;
            PointUV uv10 = uv - deltaV;
            PointUV uv11 = uv + deltaV;

            Point pCenter = Lawson.Evaluate(uv, p, q, circleAngle, inverseOffset, isInverted);

            var pxxs = new Point[] {
                Lawson.Evaluate(uv00, p, q, circleAngle, inverseOffset, isInverted),
                Lawson.Evaluate(uv01, p, q, circleAngle, inverseOffset, isInverted),
                Lawson.Evaluate(uv10, p, q, circleAngle, inverseOffset, isInverted),
                Lawson.Evaluate(uv11, p, q, circleAngle, inverseOffset, isInverted)
            };

            var sum = Vector.Zero;

            foreach (Point pxx in pxxs)
            {
                sum += pxx - pCenter;
            }

            if (sum != Vector.Zero)
            {
                return(sum.Direction);
            }

            return(Vector.Cross(pxxs[1] - pxxs[0], pxxs[1] - pxxs[2]).Direction);
        }
Ejemplo n.º 2
0
        public static Direction GetNormal(PointUV uv, double p, double q, double circleAngle, Vector inverseOffset, bool isInverted)
        {
            double delta  = 0.001;
            var    deltaU = VectorUV.Create(delta, 0);
            var    deltaV = VectorUV.Create(0, delta);

            PointUV uv00 = uv - deltaU;
            PointUV uv01 = uv + deltaU;
            PointUV uv10 = uv - deltaV;
            PointUV uv11 = uv + deltaV;

            Vector du =
                Lawson.Evaluate(uv00, p, q, circleAngle, inverseOffset, isInverted) -
                Lawson.Evaluate(uv01, p, q, circleAngle, inverseOffset, isInverted)
            ;

            Vector dv =
                Lawson.Evaluate(uv10, p, q, circleAngle, inverseOffset, isInverted) -
                Lawson.Evaluate(uv11, p, q, circleAngle, inverseOffset, isInverted)
            ;

            return(Vector.Cross(du, dv).Direction);
        }