예제 #1
0
        public override void findBounds(ref double left, ref double bottom, ref double right, ref double top)
        {
            Vector2.pointBounds(p[0], ref left, ref bottom, ref right, ref top);
            Vector2.pointBounds(p[3], ref left, ref bottom, ref right, ref top);
            Vector2 a0 = p[1] - p[0];
            Vector2 a1 = 2 * (p[2] - p[1] - a0);
            Vector2 a2 = p[3] - 3 * p[2] + 3 * p[1] - p[0];

            double[] pars = new double[2];
            int      solutions;

            solutions = EquationSolver.SolveQuadratic(pars, a2.x, a1.x, a0.x);
            for (int i = 0; i < solutions; ++i)
            {
                if (pars[i] > 0 && pars[i] < 1)
                {
                    Vector2.pointBounds(point(pars[i]), ref left, ref bottom, ref right, ref top);
                }
            }
            solutions = EquationSolver.SolveQuadratic(pars, a2.y, a1.y, a0.y);
            for (int i = 0; i < solutions; ++i)
            {
                if (pars[i] > 0 && pars[i] < 1)
                {
                    Vector2.pointBounds(point(pars[i]), ref left, ref bottom, ref right, ref top);
                }
            }
        }
예제 #2
0
        public override void findBounds(ref double left, ref double bottom, ref double right, ref double top)
        {
            Vector2.pointBounds(_p0, ref left, ref bottom, ref right, ref top);
            Vector2.pointBounds(_p3, ref left, ref bottom, ref right, ref top);
            //
            Vector2 a0 = _p1 - _p0;
            Vector2 a1 = 2 * (_p2 - _p1 - a0);
            Vector2 a2 = _p3 - 3 * _p2 + 3 * _p1 - _p0;
            //
            EqResult pars      = new EqResult();
            int      solutions = EquationSolver.SolveQuadratic(ref pars, a2.x, a1.x, a0.x);

            for (int i = 0; i < solutions; ++i)
            {
                double par = pars[i];
                if (par > 0 && par < 1)
                {
                    Vector2.pointBounds(point(par), ref left, ref bottom, ref right, ref top);
                }
            }

            pars      = new EqResult();
            solutions = EquationSolver.SolveQuadratic(ref pars, a2.y, a1.y, a0.y);

            for (int i = 0; i < solutions; ++i)
            {
                double par = pars[i];
                if (par > 0 && par < 1)
                {
                    Vector2.pointBounds(point(par), ref left, ref bottom, ref right, ref top);
                }
            }
        }