结构体定义
// Ax+By+C=0;
typedef struct Line{
double A;
double B;
double C;
}Line;
实现代码
//第一个点(x1,y1)
//第二个点(x2,y2)
Line TwoPointGetLine(double x1, double y1, double x2, double y2)
{
Line line;
line.A = (y2 - y1);
line.B = (x1 - x2);
line.C = y1 * (x2 - x1) + x1 * (y1 - y2);
if (line.B < 0)
{
line.A = -line.A;
line.B = -line.B;
line.C = -line.C;
}
return line;
}