MATLAB: Rho and theta for straight line with two end points

image processingrho theta

I have a straight line with two end points [-5.6392,6.935;-5.9014,4.56]. Could anyone please help to find out the rho (distance from the origin to the line along a vector perpendicular to the line) and theta(the angle of the perpendicular projection from the origin to the line measured in degrees clockwise from the positive x-axis) for this straight line.

Best Answer

There are two possibilities: using point A as the origin, and using point B as the origin. The rho will not change, but theta will be either pi larger or smaller.
You can use cart2pol, or even calculate it manually with x=rho*cos(theta);y=rho*sin(theta); (just do some algebra on your own to reverse the formula).
Related Question