To convert a line to Hesse normal form, you need to rewrite its equation in the form r * cos(theta) + s * sin(theta) = d
, where r
and s
are the perpendicular distances from the origin to the line, theta
is the angle between the x-axis and the line, and d
is the signed distance from the origin to the line.
Here's an example code block that takes in the slope-intercept form of a line (y = mx + b
) and converts it to Hesse normal form:
main.m824 chars21 lines
This code block will plot the original line in blue, and the line in Hesse normal form in red dashed line. Note that the axis equal
command is used to set the aspect ratio to 1:1, which ensures that the line is plotted correctly.
gistlibby LogSnag