Пример #1
0
        //-------------------------------------------------------------------------
        public static void BiSectrix(LineParameters l1,
                                     LineParameters l2,
                                     out int x, out int y)
        {
            double k  = (double)(l2.Len) / (double)(l1.Len);
            double tx = l2.X2 - (l2.X1 - l1.X1) * k;
            double ty = l2.Y2 - (l2.Y1 - l1.Y1) * k;

            //All bisectrices must be on the right of the line
            //If the next point is on the left (l1 => l2.2)
            //then the bisectix should be rotated by 180 degrees.
            if ((double)(l2.X2 - l2.X1) * (double)(l2.Y1 - l1.Y1) <
                (double)(l2.Y2 - l2.Y1) * (double)(l2.X1 - l1.X1) + 100.0)
            {
                tx -= (tx - l2.X1) * 2.0;
                ty -= (ty - l2.Y1) * 2.0;
            }

            // Check if the bisectrix is too short
            double dx = tx - l2.X1;
            double dy = ty - l2.Y1;

            if ((int)Math.Sqrt(dx * dx + dy * dy) < LineSubPixelScale)
            {
                x = (l2.X1 + l2.X1 + (l2.Y1 - l1.Y1) + (l2.Y2 - l2.Y1)) >> 1;
                y = (l2.Y1 + l2.Y1 - (l2.X1 - l1.X1) - (l2.X2 - l2.X1)) >> 1;
                return;
            }

            x = Basics.RoundInt(tx);
            y = Basics.RoundInt(ty);
        }
Пример #2
0
 //--------------------------------------------------------------------
 //public void Interpolator(ISpanInterpolator v) { m_interpolator = v; }
 //public void Filter(ImageFilterLookUpTable v) { m_filter = v; }
 public void FilterOffset(double dx, double dy)
 {
     m_dx_dbl = dx;
     m_dy_dbl = dy;
     m_dx_int = (uint)Basics.RoundInt(dx * (int)image_subpixel_scale_e.Scale);
     m_dy_int = (uint)Basics.RoundInt(dy * (int)image_subpixel_scale_e.Scale);
 }
Пример #3
0
        //---------------------------------------------fix_degenerate_bisectrix_end
        public static void FixDegenerateBisectrixEnd(LineParameters lp,
                                                     ref int x, ref int y)
        {
            int d = Basics.RoundInt(((double)(x - lp.X2) * (double)(lp.Y2 - lp.Y1) -
                                     (double)(y - lp.Y2) * (double)(lp.X2 - lp.X1)) / lp.Len);

            if (d < LineSubPixelScale / 2)
            {
                x = lp.X2 + (lp.Y2 - lp.Y1);
                y = lp.Y2 - (lp.X2 - lp.X1);
            }
        }
Пример #4
0
 public static int Conv(T x)
 {
     return(Basics.RoundInt(x.Multiply(LineAABasics.LineSubPixelScale), LineAABasics.LineMaxCoord));
 }