The standard form of the equation of a straight line in the x-y plane is: Ax + B
ID: 3582207 • Letter: T
Question
The standard form of the equation of a straight line in the x-y plane is: Ax + By + C = 0, and a point in the plane is defined by its coordinates (x_0, y_0). Write a user-defined MATLAB function that determines the distance between a point and a straight line in the x-y plane. For the function name and arguments use: d = PtoLdist (xo, yo, A, B, C) where the input arguments are the coordinates of the point and the three constants of the equation of the line. The output argument is the distance. Use the function to determine the distance for the following cases: Point: (2, -4), line: - 2x + 3.5y - 6 = 0. Point: (11, 2), line: y = -2x + 6, (note that the equation has the slope intercept form).Explanation / Answer
Function Definition :
function [d] = PtoLdist(xo,yo,A,B,C)
d = abs(A*xo + b*yo + C)/sqrt(A*A + B*B);
end
a) Point (2,-4) and Line : -2x + 3.5y - 6 = 0
distance = Ptodist(2,-4,-2,3.5,-6);
distance
= 5.937
b) Point (11,2) and Line y = -2x + 6
Line can be re-written as 2x + y - 6 = 0
distance = PtoLdist(11,2,2,1,-6);
distance
= 8.049
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.