如何在python中从另一条线的端点绘制一条垂直线? [英] How to draw a perpendicular line from the terminal point of another line in python?

查看:161
本文介绍了如何在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 problem:

给出 a线坐标和任意 length 的坐标,我想找到线段 b 的坐标(x3,y3).

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

感谢任何帮助.

更新:在此处找到了我的解决方案,并将其改编为Python,mod请将其标记为重复并关闭./p>

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

推荐答案

我认为,使用sympy模块并获得它会很容易.

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-是初始行(等式--2 x + 4 y-6)line2-是在端点(5,4)处绘制的垂直线(等式--4 x-2 y + 28)

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

请访问 https://docs.sympy.org/最新/模块/geometry/lines.html 详细了解线段.

这篇关于如何在python中从另一条线的端点绘制一条垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆