Circle Intersection in Three Dimensions
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.