找回密码
 欢迎注册
查看: 26837|回复: 10

[原创] 如何计算三维空间圆柱体间的最小距离?

[复制链接]
发表于 2020-4-28 19:06:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
如何计算三维空间圆柱体间的最小距离?
Four-cylinder-arrangements-with-the-shortest-distance-between-a-the-shells-b-a-shell.png
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-4-29 08:35:46 | 显示全部楼层
把圆柱看成直线,求两条直线的最短距离,再减去两个圆柱的半径不就可以了。

点评

这只能覆盖情形 a) 的问题,无法解决其它的 b、c、d 情形的问题  发表于 2020-4-29 11:07
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-4-29 08:51:40 | 显示全部楼层
分别列出曲面方程,求两曲面上最近的点对。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-4-29 11:29:36 | 显示全部楼层
每个圆柱由三个面和两条边界(圆)共五个对象构成,两个圆柱可以求出5*5种最短距离,首先判断每个最短距离使用的点是否在合法范围,然后此后在所有合法的最短距离中找出最终的最短距离即可
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-4-29 20:03:12 | 显示全部楼层
示例。
Degenerated-cylinder-arrangements-with-a-interpenetrating-cylinders-and-b-a-cylinder.png
Simple-geometric-elements-of-cylinders-regarded-for-the-distance-computation.png
Distance-of-axes-of-cylinders-for-fast-pretest.png
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
回复

使用道具 举报

 楼主| 发表于 2020-4-30 02:16:45 | 显示全部楼层
% [Distance,P0,P1] = dcylinders(A0, r0, A1, r1)
% Distance between 2 cylinders in 3D
% INPUTS:
%   A0: 3x2 array, each column is the end of axis of cylinder 0
%   r0: scalar, radius of cylinder 0
%   A1: 3x2 array, each column is the end of axis of cylinder 1
%   r1: scalar, radius of cylinder 1
% OUTPUTS:
%   Distance: scalar, if positive, the distance between 2 cylinders
%             meaning Distance = min{ |x-y| : x in cylinder0, y in cylinder1 }
%             where |.| is euclidian distance
%   If Distance < 0 the cylinders intersect
%   P0, P1 closest points, P0 in cylinder0, P1 in cylinder1 such that
%          Distance = |P0-P1|.
% Required: MATLAB 2018a
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-4-30 02:17:03 | 显示全部楼层
10个测试案例:
case -1
            A0 = [-2 -1 0;
                4 3 0].';
            r0 = 2.2;
            A1 = [10 -1 1;
                16 3 1].';
            r1 = 0.3;
        case 0
            A0 = [-2 -1 0;
                4 3 0].';
            r0 = 0.2;
            A1 = [-2 -1 1;
                4 3 1].';
            r1 = 0.3;
        case 1
            A0 = [-2 -1 0;
                4 3 0].';
            r0 = 0.2;
            A1 = [-1 2 1;
                5 -1 2].';
            r1 = 0.3;
        case 2
            A0 = [-2 -1 0;
                4 3 0].';
            r0 = 0.5;
            A1 = [3 0 1;
                5 -1 0].';
            r1 = 0.3;
        case 3
            A0 = [-2 -1 0;
                1 1 0].';
            r0 = 2;
            A1 = [3 2 1;
                5 1 1].';
            r1 = 1;
        case 4
            A0 = [-2 -1 0;
                1 1 0].';
            r0 = 1;
            A1 = [3 0 1;
                5 -1 0].';
            r1 = 0.5;
        case 5
            A0 = [-2 0 0;
                5 0 0].';
            r0 = 1;
            A1 = [1 3 1;
                1 7 1].';
            r1 = 1.2;
        case 6
            A0 = [-2 0 0;
                5 0 0].';
            r0 = 0.5;
            A1 = [1 2 0;
                  4 1 0].';
            r1 = 0.5;
        case 7
            A0 = [-3 0 0;
                  0 0 0].';
            r0 = 3;
            A1 = [0.5 0 -0.5;
                  3.5 3 0].';
            r1 = 2;
         case 8
            A0 = [-3 0 0;
                  0 0 0].';
            r0 = 0.2;
            A1 = [0.5 0 0.2;
                  -3 -3 0].';
            r1 = 0.2;      

>> test_dcylinders
Compile conv1使用 'Microsoft Visual C++ 2013 (C)' 编译。
MEX 已成功完成。

Distance =

    0.0091


Distance =

   -1.8432


Distance =

    0.0257


Distance =

     2


Distance =

    1.2818


Distance =

    1.3506


Distance =

    1.4315


Distance =

    0.8141


Distance =

    0.5000


Distance =

    5.0591

>>
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-4-30 02:20:09 | 显示全部楼层
部分计算图像示例
1.jpg
4.jpg
9.jpg
10.jpg
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-5-4 11:09:57 | 显示全部楼层
本帖最后由 灵树 于 2020-5-4 11:20 编辑

可以化简为求两线轴心线和端面上与另一个轴心线垂直的半径,这样几条线段空间距离的问题,
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-5-8 20:12:56 | 显示全部楼层
正方体内随机投放圆柱体,达到预定的体积比例;判断两圆柱体间的距离,距离为负即为相交,为正,不相交。

1

1

2

2
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-27 07:25 , Processed in 0.050490 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表