# 图像处理；C++求已知两直线方程交点

3 篇文章 0 订阅

F0(x) = a0*x + b0*y + c0 = 0, F1(x) = a1*x + b1*y + c1 = 0

a0*x + b0*y +c0 = a1*x + b1*y + c1

x = (b0*c1 – b1*c0)/D
y = (a1*c0 – a0*c1)/D
D = a0*b1 – a1*b0， (D为0时，表示两直线平行)

void GetCrossPoint(float A1, float B1, float A3, float B3,int count,vector<Point2d>& cross_Pt)
{
int L1x0 = 1, L1x1 = 500, L3x0 = 1, L3x1 = 500;   //像素坐标X上随便取两点
float L1y0 = A1*L1x0 + B1;                        //根据已知直线方程求对应的Y值
float L1y1 = A1*L1x1 + B1;
float L3y0 = A3*L3x0 + B3;
float L3y1 = A3*L3x1 + B3;
float a1 = L1y0 - L1y1;
float b1 = L1x1 - L1x0;
float c1 = L1x0*L1y1 - L1x1*L1y0;
float a3 = L3y0 - L3y1;
float b3 = L3x1 - L3x0;
float c3 = L3x0*L3y1 - L3x1*L3y0;
float D = a1*b3 - a3*b1;
double x = (b1*c3 - b3*c1) / D;
double y = (a3*c1 - a1*c3) / D;
Point2d tmp_pt;
tmp_pt.x = x;
tmp_pt.y = y;
cross_Pt.push_back(tmp_pt);
}
• 5
点赞
• 11
收藏
觉得还不错? 一键收藏
• 0
评论
03-23 604
08-27
07-13
08-21
08-12
09-11
05-19 2020
01-27 4038

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。