相关疑难解决方法(0)

得到最近的一条线

我想有一个直接的C#函数来获得最近点(从点P)到线段AB.抽象函数可能如下所示.我搜索了SO,但没有找到可用的(由我)解决方案.

public Point getClosestPointFromLine(Point A, Point B, Point P);
Run Code Online (Sandbox Code Playgroud)

c# math geometry

32
推荐指数
5
解决办法
4万
查看次数

在多边形上找到最近点的坐标

说我有以下多边形和点:

>>> poly = Polygon([(0, 0), (2, 8), (14, 10), (6, 1)])
>>> point = Point(12, 4)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我可以计算点到多边形的距离......

>>> dist = point.distance(poly)
>>> print(dist)
2.49136439561
Run Code Online (Sandbox Code Playgroud)

...但我想知道最短距离所测量的多边形边界上的点的坐标.

我最初的方法是通过它与多边形的距离缓冲点,并找到该圆与多边形相切的点:

>>> buff = point.buffer(dist) 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 但是,我不确定如何计算这一点.两个多边形不相交,所以list(poly.intersection(buff))不会给我这一点.

我是否在正确的轨道上?有更简单的方法吗?

python shapely

20
推荐指数
2
解决办法
1万
查看次数

Python 3.5.2:点到线的距离

我创建了一个“点”类,我想计算给定点和线(以其他 2 个点为特征)之间的最短距离,所有点都是已知的。我尝试使用这个公式:|Ax+By+C| / sqrt(A^2+B^2) ,但我搞砸了,一分钟后变得更加困惑(主要是因为数学公式:()...

我确实找到了一些人们也问这个问题的网站,但它要么不是针对 Python 的,要么是在 3D 系统中而不是 2D ...

??
下面是我的课:

class Point:
        def __init__(self,initx,inity):
            self.x = initx
            self.y = inity
        def getX(self):
            return self.x
        def getY(self):
            return self.y
        def __str__(self):
            return "x=" + str(self.x) + ", y=" + str(self.y)
        def distance_from_point(self,the_other_point):
            dx = the_other_point.getX() - self.x
            dy = the_other_point.getY() - self.y
        def slope(self,other_point):
            if self.x - other_point.getX() == 0 :
                return 0
            else:
                panta = (self.y - other_point.getY())/ (self.x - other_point.getX())
                return panta
Run Code Online (Sandbox Code Playgroud)

有人可以帮我写一个单独的函数或方法来做我想要的吗?我试了2个小时,我无法弄清楚......

python point distance line python-3.x

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

c# ×1

distance ×1

geometry ×1

line ×1

math ×1

point ×1

python-3.x ×1

shapely ×1