python 立体图 交叉 平面,Python形状相交:平行平面

I'm working on determining relationships (boundary/interior intersections) between two 3D objects (triangular faces) and stumbled on shapely, which I am interested in using instead of implementing my own point/segment/ray/triangle intersection functions.

However, I'm running into the following problem:

>>> from shapely.geometry import Polygon

>>> poly = Polygon([(0,1,1),(1,-1,1),(-1,-1,1)])

>>> poly2 = Polygon([(0,1,0),(1,-1,0),(-1,-1,0)])

>>> poly.intersects(poly2)

True

>>> poly.equals(poly2)

True

The problem I seem to be running into is that the two polygons are equal in their 2D orthogonal projections (same triangle), but in different planes (one's at Z=1, other at Z=0), but shapely is saying they're equal and intersect.

Is there some magic I'm missing to make shapely think in 3 dimensions? I've been googling, but every example I've seen so far is only in two dimensions.

解决方案

According to the Shapely manual, it states that the following for the z coordinate plane for geometric objects:

A third z coordinate value may be used when constructing instances, but has no effect on geometric analysis. All operations are performed in the x-y plane.

If your calculations require the z coordinate plane, then Shapely might not be for you. Of course, you could try to get the points of the polygon as a list and compare it to other polygons. However, if you want to have a Python geometric library that can handle the z dimension, you can find some here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值