查找海拔与基准相交的点(Python)

编程入门 行业动态 更新时间:2024-10-23 17:34:47
本文介绍了查找海拔与基准相交的点(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

仅给出一个锐角三角形顶点的坐标,我如何有效而快速地找到某个特定顶点的高度与相反的底点相交的点的坐标?

Given only the coordinates of the vertices of an acute triangle, how can I efficiently and quickly find the coordinates of the point at which the altitude from a particular vertex meets the opposite base?

仅使用数学,numpy或scipy的解决方案将非常有用.

A solution using only math, numpy, or scipy would be incredibly helpful.

推荐答案

需要的点是顶点(例如顶点C)在包含相反面(例如AB)的线上的正交投影.

Needed point is orthogonal projection of vertex point (say vertex C) onto the line containing opposite side (say AB).

要找到投影点,请获取AB和AC的向量

To find projection point, get vectors for AB and AC

AB = (B - A) //in coordinates ab.x = b.x-a.x, ab.y = b.y-a.y AC = (C - A)

并使用AB和AC的标量积查找参数

and find parameter using scalar product of AB and AC

t =(AB * AC) / (AB * AB) t =((b.x-a.x)*(c.x-a.x) + (b.y-a.y)*(c.y-a.y)) / ((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y))

投影点坐标

P = A + AB * t p.x = a.x + (b.x-a.x) * t p.y = a.y + (b.y-a.y) * t

仅此而已

def orthoProjection(ax, ay, bx, by, cx, cy): abx = bx - ax aby = by - ay acx = cx - ax acy = cy - ay t = (abx * acx + aby * acy) / (abx * abx + aby * aby) px = ax + t * abx py = ay + t * aby return px, py print(orthoProjection(0, 0, 4, 4, -1, 5)) >>(2.0, 2.0)

更多推荐

查找海拔与基准相交的点(Python)

本文发布于:2023-11-29 08:39:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645896.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:基准   海拔   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!