Skip to content Skip to sidebar Skip to footer

How To Draw A Perpendicular Line From The Terminal Point Of Another Line In Python?

I'm trying to draw a line segment orthogonal/perpendicular to the current line segment from the terminal point for a given length, here's an illustration to help better explain the

Solution 1:

I think, it would be easy to use sympy module and get it.

import sympy.geometryas gm
line1=gm.Line(gm.Point(1,2),gm.Point(5,4))
line2=line1.perpendicular_line(line1.p2)

line1 - is the initial line ( equation- -2x + 4y - 6) line2- is the perpendicular line drawn at the endpoint (5,4) (equation - -4x - 2y + 28)

Pleas have a look at https://docs.sympy.org/latest/modules/geometry/lines.html for line segments in detail.

Post a Comment for "How To Draw A Perpendicular Line From The Terminal Point Of Another Line In Python?"