3dgeometryplanegreat-circleanalytical

Circle-Circle Intersection in 3D space


I have 2 circles C1 and C2 which lies on 2 different planes in 3D space. I want to intersect those circles and find the intersection points.

Inputs :

C1(x,y,z), Radius R1 and Plane P1

C2(x,y,z), Radius R2 and Plane P2.

For 2D we can do it easily with the equation of circle but in this case, I'm unable to do the same.


Solution

  • I got the solution by using CGAL library. This library gives solutions for these kind of various mathematical problems. Here, I know the planes of 2 circle and I can use plane of 1 circle to intersect the other.Refer to this below code.

    #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;
    }