get point from line

 public float lineFromPoints(PointF P, PointF Q, float x)
    {
        float a = Q.y - P.y;
        float b = P.x - Q.x;
        float c = a*(P.x) + b*(P.y);
        float y;
        float tmpx;
        if(b < 0)
        {
            tmpx=x+deviation;
//            Log.d("jia","-The line passing through points P and Q is: "
//                    + a + "x " + b + "y = " + c);
            y=(float)(a*tmpx-c)/(float)Math.abs(b);

        }
        else
        {
            tmpx=x-deviation;

//            Log.d("jia","+The line passing through points P and Q is: "
//                    + a + "x + " + b + "y = " + c);
            y=(float)(c-a*tmpx)/(float)Math.abs(b);

        }
//        Log.d("jia","+The line passing through y="+y);
        return y;
    }

猜你喜欢

转载自blog.csdn.net/jiabailong/article/details/107544353
今日推荐