繁体   English   中英

3D 空间中的圆-圆交点

[英]Circle-Circle Intersection in 3D space

我有 2 个圆C1C2 ,它们位于 3D 空间的 2 个不同平面上。 我想与这些圆圈相交并找到交点。

输入:

C1(x,y,z),半径 R1 和平面 P1

C2(x,y,z)、半径 R2 和平面 P2。

对于 2D,我们可以使用圆方程轻松完成,但在这种情况下,我无法做到这一点。

我通过使用CGAL库得到了解决方案。 这个库为这些类型的各种数学问题提供了解决方案。 在这里,我知道 2 个圆的平面,我可以使用 1 个圆的平面与另一个相交。请参阅下面的代码。

#include <CGAL/Exact_spherical_kernel_3.h>
typedef CGAL::Exact_spherical_kernel_3               SK;
typedef CGAL::Sphere_3<SK>                           sphere3Sk;
typedef CGAL::Point_3<SK>                            point3Sk;
typedef CGAL::Circle_3<SK>                           circle3Sk;
typedef CGAL::Circular_arc_point_3<SK>               circularArcSk;
typedef CGAL::Plane_3<SK>                            planeSk;
typedef CGAL::Vector_3<SK>                           vec3SK;

QList<QVector3D*> intersectPlaneCircle(planeSk pl, circle3Sk c2) {
    QList<QVector3D*> retVal;
    SK::Intersect_3 inter;
    std::vector< CGAL::Object > opVec;
    inter(pl,c2,std::back_inserter(opVec));

    std::pair<circularArcSk,unsigned> p1=
            CGAL::object_cast< std::pair<circularArcSk,unsigned> >(opVec[0]);
    std::pair<circularArcSk,unsigned> p2=
            CGAL::object_cast< std::pair<circularArcSk,unsigned> >(opVec[1]);

    retVal.append(new QVector3D(CGAL::to_double(p1.first.x()), 
    CGAL::to_double(p1.first.y()), CGAL::to_double(p1.first.z())));
    retVal.append(new QVector3D(CGAL::to_double(p2.first.x()), 
    CGAL::to_double(p2.first.y()), CGAL::to_double(p2.first.z())));
    return retVal;
}

math.stackexchange.com 也许这是问问题的地方,更多的数学家

暂无
暂无

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

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