示例#1
0
 public void Init(double x1, double y1,
                  double cx1, double cy1,
                  double cx2, double cy2,
                  double x2, double y2)
 {
     if (m_approximation_method == Curves.CurveApproximationMethod.Inc)
     {
         m_curve_inc.Init(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
     }
     else
     {
         m_curve_div.Init(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
     }
 }
示例#2
0
        static void CreateBezierVxs4(VertexStore vxs,
                                     double x0, double y0,
                                     double x1, double y1,
                                     double x2, double y2,
                                     double x3, double y3)
        {
            //1. subdiv technique

            s_curve4Div.Init(x0, y0, x1, y1, x2, y2, x3, y3);
            ArrayList <Vector2> points = s_curve4Div.GetInternalPoints();

            int n = 0;

            for (int i = points.Length - 1; i >= 0; --i)
            {
                Vector2 p = points[n++];
                vxs.AddLineTo(p.x, p.y);
            }


            //----------------------------------------
            //2. old tech --  use incremental
            //var curve = new VectorMath.BezierCurveCubic(
            //    start, end,
            //    control1, control2);
            //vxs.AddLineTo(start.x, start.y);
            //float eachstep = (float)1 / NSteps;
            //float stepSum = eachstep;//start
            //for (int i = NSteps - 1; i >= 0; --i)
            //{
            //    var vector2 = curve.CalculatePoint(stepSum);
            //    vxs.AddLineTo(vector2.x, vector2.y);
            //    stepSum += eachstep;
            //}
            //vxs.AddLineTo(end.x, end.y);
        }