1

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 problem:

Sample

Given the line a coordinates and an arbitrary length, I'd like to find the coordinates for line segment b and (x3,y3).

Appreciate any help.

UPDATE: Found my solution here and adapted it to Python, mods please mark this as duplicate and close it.

HumbleBee
  • 1,212
  • 13
  • 20

1 Answers1

4

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

import sympy.geometry as 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.

  • I'd like to delete this question since it was a duplicate, would appreciate if you deleted your answer so that I can delete the question. Thank you. – HumbleBee Apr 11 '21 at 08:43