首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有有限个症状段的Bug

具有有限个症状段的Bug
EN

Stack Overflow用户
提问于 2019-09-29 03:21:02
回答 2查看 34关注 0票数 1

我正在与12个线段的平面相交,这些线段代表一个立方体的边。我的问题是,所有的交叉点都会产生一个点,即使这个点不应该是线段的一部分,因为它们应该是有限的,对吧?

代码:

代码语言:javascript
复制
from sympy import Point3D, Plane, intersection, Segment3D

# Cube's vertices
v = (Point3D(500, 500, 500), Point3D(-500, 500, 500), Point3D(-500, -500, 500),
     Point3D(500, -500, 500), Point3D(500, 500, -500), Point3D(-500, 500, -500),
     Point3D(-500, -500, -500), Point3D(500, -500, -500))
# Cube´s edges
a = (Segment3D(v[0], v[1]), Segment3D(v[1], v[2]),
     Segment3D(v[2], v[3]), Segment3D(v[3], v[0]),
     Segment3D(v[0], v[4]), Segment3D(v[1], v[5]),
     Segment3D(v[2], v[6]), Segment3D(v[3], v[7]),
     Segment3D(v[4], v[5]), Segment3D(v[5], v[6]),
     Segment3D(v[6], v[7]), Segment3D(v[7], v[4]))

# Example plane which should generate 3 points
plano = Plane(Point3D(450, 400, 400), Point3D(400, 450, 400), Point3D(400, 400, 450))

bad = []
good = []
for i in range(12):
    inter = intersection(plano, a[i])
    # This should be executed when the intersection generates anything, but is always executed:
    if inter:
        bad.append(inter[0])
        # This comparation should not be necessary, checks if point is in range desired
        if abs(inter[0][0]) <= 500 and abs(inter[0][1]) <= 500 and abs(inter[0][2]) <= 500: 
            good.append(inter[0])

print(len(bad), bad)
print(len(good), good)

输出:

代码语言:javascript
复制
12 [Point3D(250, 500, 500), Point3D(-500, 1250, 500), Point3D(1250, -500, 500), Point3D(500, 250, 500), Point3D(500, 500, 250), Point3D(-500, 500, 1250), Point3D(-500, -500, 2250), Point3D(500, -500, 1250), Point3D(1250, 500, -500), Point3D(-500, 2250, -500), Point3D(2250, -500, -500), Point3D(500, 1250, -500)]
3 [Point3D(250, 500, 500), Point3D(500, 250, 500), Point3D(500, 500, 250)]

12个点中有9个不属于任何线段

EN

回答 2

Stack Overflow用户

发布于 2019-09-29 04:08:38

此问题已在SymPy主程序上修复,但尚未发布版本。在master上我得到:

代码语言:javascript
复制
3 [Point3D(250, 500, 500), Point3D(500, 250, 500), Point3D(500, 500, 250)]
3 [Point3D(250, 500, 500), Point3D(500, 250, 500), Point3D(500, 500, 250)]

(我假设这是您所期望的)

票数 0
EN

Stack Overflow用户

发布于 2019-09-29 04:08:38

这目前是一个bug (在1.4或更早的时候),并将在1.5版本中修复。https://github.com/sympy/sympy/pull/16637

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58149569

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档