简体   繁体   English

Python-互补齿轮形状

[英]Python - Complementary gear shape

I'm trying to find the complementary rotary "gear" shape to any input polygon shape. 我试图找到与任何输入多边形形状互补的旋转“齿轮”形状。 For example this polygon, is rotated around so that the complementary gear becomes apparent. 例如,该多边形绕着旋转,使得互补齿轮变得明显。 Both shapes would be able to rotate without interferences. 两种形状都将能够旋转而不会产生干扰。

I'm having issues defining the second polygon, which is the edge of the white inner region. 我在定义第二个多边形(即白色内部区域的边缘)时遇到问题。 One method I can think of is "sampling" the input shape along its circumference, and rotating like before to generate a pointcloud. 我能想到的一种方法是沿输入形状的圆周“采样”并像以前一样旋转以生成点云。 A concave hull algorithm (Alpha shape) could be used to obtain the edge. 可以使用凹壳算法(Alpha形状)来获取边缘。

While this would work, I feel there must be a more elegant solution to this problem. 尽管这可行,但我认为必须有一个更优雅的解决方案。

Thanks 谢谢

齿轮 Polygon and its rotated image 多边形及其旋转的图像

采样形状 Sampled polygon and resulting pointcloud 采样的多边形和结果点云

变焦边缘 close up of edge 边缘的特写

I figured it out. 我想到了。 The solution is to track all vertices and a special point for each edge. 解决方案是跟踪所有顶点以及每个边的特殊点。 Then, the inner gear shape can be extracted by doing an intersection of all obtained curves. 然后,可以通过对所有获得的曲线进行交点来提取内齿轮形状。

The contact point on the edges is the point on that edge which is closest to the instantaneous rotation center of the gear, which is the point where the two base circles touch. 边缘上的接触点是该边缘上最接近齿轮瞬时旋转中心的点,这是两个基圆接触的点。

I'm using shapely to do the intersections. 我正在匀称地做交点。

I tried uploading the gif but that didn't work, so here is a link: 我尝试上传gif,但没有成功,因此这里是一个链接:

https://photos.app.goo.gl/nuYUv03ZWTYpFJrq2 https://photos.app.goo.gl/nuYUv03ZWTYpFJrq2

测试

Thanks guys, I solved it. 谢谢大家,我解决了。 The solution is to track each vertex and contact point on each edge. 解决方案是跟踪每个顶点和每个边缘上的接触点。 The contact point is the point on that edge closest to the instantaneous rotation center, which is the point where the two base circles touch. 接触点是最靠近瞬时旋转中心的那个边缘上的点,这是两个基圆接触的点。

I then use shapely to find the intersection of all obtained shapes, which represents the inner gear. 然后,我使用整形找到所有获得的形状的交点,它们代表了内齿轮。

I tried uploading a gif, but that's not working so here it is instead: 我尝试上传gif,但无法正常工作,因此这里是:

https://photos.app.goo.gl/nuYUv03ZWTYpFJrq2 https://photos.app.goo.gl/nuYUv03ZWTYpFJrq2

测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM