intersection_sphere_sphere

compas.geometry.intersection_sphere_sphere(sphere1, sphere2)[source]

Computes the intersection of 2 spheres.

There are 4 cases of sphere-sphere intersection : 1) the spheres intersect in a circle, 2) they intersect in a point, 3) they overlap, 4) they do not intersect.

Parameters
  • sphere1 (tuple) – center, radius of the sphere.

  • sphere2 (tuple) – center, radius of the sphere.

Returns

  • case (str) – point, circle, or sphere

  • result (tuple) –

    • point: xyz coordinates

    • circle: center, radius, normal

    • sphere: center, radius

Examples

>>> sphere1 = (3.0, 7.0, 4.0), 10.0
>>> sphere2 = (7.0, 4.0, 0.0), 5.0
>>> result = intersection_sphere_sphere(sphere1, sphere2)
>>> if result:
...     case, res = result
...     if case == "circle":
...         center, radius, normal = res
...     elif case == "point":
...         point = res
...     elif case == "sphere":
...         center, radius = res

References

https://gamedev.stackexchange.com/questions/75756/sphere-sphere-intersection-and-circle-sphere-intersection