//----------------------------------------------------------------
        public void Begin(double x, double y, uint len)
        {
            // Calculate transformed Coordinates At x1,y1
            double xt = x;
            double yt = y;

            m_trans_dir.Transform(ref xt, ref yt);
            int x1 = Basics.Round(xt * subpixel_scale);
            int y1 = Basics.Round(yt * subpixel_scale);

            double dx;
            double dy;
            double delta = 1 / (double)subpixel_scale;

            // Calculate Scale by X At x1,y1
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx1 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x1,y1
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy1 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate transformed Coordinates At x2,y2
            x += len;
            xt = x;
            yt = y;
            m_trans_dir.Transform(ref xt, ref yt);
            int x2 = Basics.Round(xt * subpixel_scale);
            int y2 = Basics.Round(yt * subpixel_scale);

            // Calculate Scale by X At x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_coord_y = new Dda2LineInterpolator(y1, y2, (int)len);
            m_scale_x = new Dda2LineInterpolator(sx1, sx2, (int)len);
            m_scale_y = new Dda2LineInterpolator(sy1, sy2, (int)len);
        }
        //----------------------------------------------------------------
        public void ReSynchronize(double xe, double ye, uint len)
        {
            // Assume x1,y1 are equal to the ones At the previous End point
            int x1  = m_coord_x.y();
            int y1  = m_coord_y.y();
            int sx1 = m_scale_x.y();
            int sy1 = m_scale_y.y();

            // Calculate transformed Coordinates At x2,y2
            double xt = xe;
            double yt = ye;

            m_trans_dir.Transform(ref xt, ref yt);
            int x2 = Basics.Round(xt * subpixel_scale);
            int y2 = Basics.Round(yt * subpixel_scale);

            double delta = 1 / (double)subpixel_scale;
            double dx;
            double dy;

            // Calculate Scale by X At x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sx2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sy2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_coord_y = new Dda2LineInterpolator(y1, y2, (int)len);
            m_scale_x = new Dda2LineInterpolator(sx1, sx2, (int)len);
            m_scale_y = new Dda2LineInterpolator(sy1, sy2, (int)len);
        }
예제 #3
0
        //--------------------------------------------------------------------
        public LineBresenhamInterpolator(int x1, int y1, int x2, int y2)
        {
            m_x1_lr = (line_lr(x1));
            m_y1_lr = (line_lr(y1));
            m_x2_lr = (line_lr(x2));
            m_y2_lr = (line_lr(y2));
            m_ver   = (Math.Abs(m_x2_lr - m_x1_lr) < Math.Abs(m_y2_lr - m_y1_lr));
            if (m_ver)
            {
                m_len = (uint)Math.Abs(m_y2_lr - m_y1_lr);
            }
            else
            {
                m_len = (uint)Math.Abs(m_x2_lr - m_x1_lr);
            }

            m_inc          = (m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1));
            m_interpolator = new Dda2LineInterpolator(m_ver ? x1 : y1,
                                                      m_ver ? x2 : y2,
                                                      (int)m_len);
        }
        //----------------------------------------------------------------
        public void ReSynchronize(double xe, double ye, uint len)
        {
            // Assume x1,y1 are equal to the ones At the previous End point
            int x1 = m_coord_x.y();
            int y1 = m_coord_y.y();
            int sx1 = m_scale_x.y();
            int sy1 = m_scale_y.y();

            // Calculate transformed Coordinates At x2,y2
            double xt = xe;
            double yt = ye;
            m_trans_dir.Transform(ref xt, ref yt);
            int x2 = Basics.Round(xt * subpixel_scale);
            int y2 = Basics.Round(yt * subpixel_scale);

            double delta = 1 / (double)subpixel_scale;
            double dx;
            double dy;

            // Calculate Scale by X At x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sx2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sy2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_coord_y = new Dda2LineInterpolator(y1, y2, (int)len);
            m_scale_x = new Dda2LineInterpolator(sx1, sx2, (int)len);
            m_scale_y = new Dda2LineInterpolator(sy1, sy2, (int)len);
        }
        //----------------------------------------------------------------
        public void Begin(double x, double y, uint len)
        {
            // Calculate transformed Coordinates At x1,y1
            double xt = x;
            double yt = y;
            m_trans_dir.Transform(ref xt, ref yt);
            int x1 = Basics.Round(xt * subpixel_scale);
            int y1 = Basics.Round(yt * subpixel_scale);

            double dx;
            double dy;
            double delta = 1 / (double)subpixel_scale;

            // Calculate Scale by X At x1,y1
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx1 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x1,y1
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy1 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate transformed Coordinates At x2,y2
            x += len;
            xt = x;
            yt = y;
            m_trans_dir.Transform(ref xt, ref yt);
            int x2 = Basics.Round(xt * subpixel_scale);
            int y2 = Basics.Round(yt * subpixel_scale);

            // Calculate Scale by X At x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate Scale by Y At x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy2 = (int)Basics.UnsignedRound(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_coord_y = new Dda2LineInterpolator(y1, y2, (int)len);
            m_scale_x = new Dda2LineInterpolator(sx1, sx2, (int)len);
            m_scale_y = new Dda2LineInterpolator(sy1, sy2, (int)len);
        }
예제 #6
0
        //--------------------------------------------------------------------
        public LineBresenhamInterpolator(int x1, int y1, int x2, int y2)
        {
            m_x1_lr=(line_lr(x1));
            m_y1_lr=(line_lr(y1));
            m_x2_lr=(line_lr(x2));
            m_y2_lr=(line_lr(y2));
            m_ver=(Math.Abs(m_x2_lr - m_x1_lr) < Math.Abs(m_y2_lr - m_y1_lr));
            if (m_ver)
            {
                m_len = (uint)Math.Abs(m_y2_lr - m_y1_lr);
            }
            else
            {
                m_len = (uint)Math.Abs(m_x2_lr - m_x1_lr);
            }

            m_inc=(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1));
            m_interpolator= new Dda2LineInterpolator(m_ver ? x1 : y1,
                           m_ver ? x2 : y2,
                           (int)m_len);
        }