直线方程公式

此处总结常见的算法,尽可能的记住..

1.两点式直线方程:a * x + b * y + c = 0;

float a1= centerPostionToUse.y - point1ToUse.y;
float b1= point1ToUse.x - centerPostionToUse.x;
float c1 = point1ToUse.x*(point1ToUse.y - centerPostionToUse.y) - point1ToUse.y*(point1ToUse.x - centerPostionToUse.x);

已知两点p1,p2
a = p2.y - p1.y;
b = p1.x - p2.x;
c = p1.x * (p1.y - p2.y) - p1.y * (p1.x - p2.x);

2.已知顶点p(x,y),计算点到直线的距离:
dis = abs(a * x + b * y + c)/sqrt(a * a + b * b);

垂足czPoint求算:
czPoint.x = (b * b * curpoint.x - a * b * curpoint.y - a * c)/(a * a + b * b);
czPoint.y = (a * a * curpoint.y - a * b * curpoint.x - b * c)/(a * a + b * b);

3.已知直线l方程a * x + b * y + c = 0;和点p(x1,y1)
计算过p1点且与直线l垂直的直线方程为a2 * x + b2 * y + c2 = 0;
则a2 = b;
b2 = -a;
c2 = a * (y1 - b/a * x1);

 

后续更新中....

posted @ 2016-09-23 15:58  bky2016  阅读(1495)  评论(0编辑  收藏  举报