Esempio n. 1
0
        private void C1()
        {
            G1();

            Point2D p0 = BSplineControlPoints[BSplineControlPoints.Count - 2];
            Point2D p1 = BezierControlPoints.First();
            Point2D p2 = BezierControlPoints[1];

            BezierCurve.Scale(
                new PointF(
                    (p1.Location.X - p0.Location.X) / (p2.Location.X - p1.Location.X),
                    (p1.Location.Y - p0.Location.Y) / (p2.Location.Y - p1.Location.Y)
                    ),
                p1.Location
                );

            float scale = BSplineCurve.Degree / (
                BSplineCurve.Knots[BSplineCurve.ControlPointsNum - 1 + BSplineCurve.Degree] -
                BSplineCurve.Knots[BSplineCurve.ControlPointsNum - 1]
                );

            scale /= BezierCurve.Degree;

            BezierCurve.Scale(new PointF(scale, scale), p1.Location);
        }
Esempio n. 2
0
        private void C0()
        {
            float deltaX = BSplineControlPoints.Last().Location.X - BezierControlPoints.First().Location.X;
            float deltaY = BSplineControlPoints.Last().Location.Y - BezierControlPoints.First().Location.Y;

            foreach (Point2D p in BezierControlPoints)
            {
                p.Location.X += deltaX;
                p.Location.Y += deltaY;
            }
        }
Esempio n. 3
0
        private void G1()
        {
            C0();

            Point2D p0 = BSplineControlPoints[BSplineControlPoints.Count - 2];
            Point2D p1 = BezierControlPoints.First();
            Point2D p2 = BezierControlPoints[1];

            float angle = 0;

            if (p1.Location.X - p0.Location.X <= 0 && p1.Location.Y - p0.Location.Y <= 0)
            {
                angle = (float)PI;
            }
            else if (p1.Location.X - p0.Location.X >= 0 && p1.Location.Y - p0.Location.Y <= 0)
            {
                angle = (float)(PI / 2);
            }
            else if (p1.Location.X - p0.Location.X <= 0 && p1.Location.Y - p0.Location.Y >= 0)
            {
                angle = (float)(-PI / 2);
            }

            BSplineCurve.Rotate(angle, p1.Location);

            if (p2.Location.X - p1.Location.X <= 0 && p2.Location.Y - p1.Location.Y <= 0)
            {
                BezierCurve.Rotate((float)PI, p1.Location);
            }
            else if (p2.Location.X - p1.Location.X >= 0 && p2.Location.Y - p1.Location.Y <= 0)
            {
                BezierCurve.Rotate((float)(PI / 2), p1.Location);
            }
            else if (p2.Location.X - p1.Location.X <= 0 && p2.Location.Y - p1.Location.Y >= 0)
            {
                BezierCurve.Rotate((float)(-PI / 2), p1.Location);
            }

            BezierCurve.Rotate(
                (float)(Atan(Abs(p2.Location.X - p1.Location.X) / Abs(p2.Location.Y - p1.Location.Y)) -
                        Atan(Abs(p1.Location.X - p0.Location.X) / Abs(p1.Location.Y - p0.Location.Y))),
                p1.Location);

            BezierCurve.Rotate(-angle, p1.Location);
            BSplineCurve.Rotate(-angle, p1.Location);
        }