How can I find the general form equation of a line from two points?

前端 未结 5 1955
野的像风
野的像风 2021-02-02 09:48

Given the input:

double x1,y1,x2,y2;

How can I find the general form equation (double a,b,c where ax + b

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 09:58

    Get the tangent by subtracting the two points (x2-x1, y2-y1). Normalize it and rotate by 90 degrees to get the normal vector (a,b). Take the dot product with one of the points to get the constant, c.

提交回复
热议问题