Circle Intersection in Three Dimensions
Updated
Problem statement
Each circle is a circumference in three-dimensional space. Circle i consists of points in the plane through center_i perpendicular to normal_i whose Euclidean distance from the center is exactly radius_i. A normal is not required to have length one.
Return true if the two circumferences share at least one point, and false otherwise. Count external or internal tangency and coincident circles as intersecting. Points inside a circle are not part of its circumference.
Function
circlesIntersect3D(center1: int[], normal1: int[], radius1: int, center2: int[], normal2: int[], radius2: int) → booleanExamples
Example 1
center1 = [0, 0, 0]normal1 = [0, 0, 1]radius1 = 2center2 = [3, 0, 0]normal2 = [0, 0, 1]radius2 = 2return = trueThe two coplanar circumferences cross at two points.
Example 2
center1 = [0, 0, 0]normal1 = [0, 0, 1]radius1 = 2center2 = [0, 0, 1]normal2 = [0, 0, 1]radius2 = 2return = falseThe planes have equal normals but different heights, so their circles share no point.
Example 3
center1 = [0, 0, 0]normal1 = [0, 0, 1]radius1 = 1center2 = [0, 0, 0]normal2 = [0, 1, 0]radius2 = 1return = trueThe planes meet on the x-axis, and both circles contain (1,0,0) and (-1,0,0).
Example 4
center1 = [0, 0, 0]normal1 = [0, 0, 1]radius1 = 1center2 = [1, 0, 1]normal2 = [1, 0, 0]radius2 = 1return = trueThe planes meet on x=1, z=0. Their only shared circumference point is (1,0,0).
Constraints
- Each center and normal has exactly three integer components.
- Center components are in
[-20, 20]. - Normal components are in
[-1, 1], and each normal is nonzero. 1 <= radius1, radius2 <= 20.
More NVIDIA Onsite Interview questions
- Check Endianness Of A Byte ArrayONSITE INTERVIEW · Seen Sep 2026
- Implement MallocONSITE INTERVIEW · Seen Sep 2026
- Implement PrintfONSITE INTERVIEW · Seen Sep 2026
- Merge Two Arrays Into Sorted OrderONSITE INTERVIEW · Seen Sep 2026
- Middle Node Of A Linked ListONSITE INTERVIEW · Seen Sep 2026
- Ping Reply TrackingONSITE INTERVIEW · Seen Sep 2026
- Reverse A StringONSITE INTERVIEW · Seen Sep 2026
- Maximum Fish in a GridONSITE INTERVIEW · Seen Sep 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- First Register Overflow TickONSITE INTERVIEW · Seen May 2024
Similar questions at other companies
- Max Points on a LineLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Max Points on a LineMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Bounding Box Intersection over UnionGoogle · ONSITE INTERVIEWGoogle interview questions
- Rasterize a Circle with Integer PixelsPure Storage · ONSITE INTERVIEWPure Storage interview questions
- Correct Three Protractor ReadingsSusquehanna International Group (SIG) · ONSITE INTERVIEWSusquehanna International Group (SIG) interview questions
- Point Inside a TriangleSambaNova Systems · PHONE SCREEN · ONSITE INTERVIEWSambaNova Systems interview questions
- Overlap Area of Two RectanglesNutanix · ONSITE INTERVIEWNutanix interview questions
- Common Part of Two RectanglesExpedia · ONSITE INTERVIEWExpedia interview questions
- Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
- Max Points on a LineUber · PHONE SCREENUber interview questions