I am now engaged in moving the sphere in space with collisions with other objects. There were problems with solving the problem of the intersection of a sphere and a triangle (of which my polyhedra are composed).
Given the coordinates of the center of the sphere and its radius, as well as three points of the triangle in space. You need to find out if the triangle intersects the sphere (by its side or area).
Even more formally: Given a point O(x0, y0, z0) – the center of a sphere. Given a real number r – the radius of the sphere. Three vertices of a triangle are given: A(x1, y1, z1), B(x2, y2, z2), C(x3, y3, z3). It is necessary to answer the question: does the triangle have at least one common point with the sphere?
Recommended sequence of actions.
- Construct the plane of the triangle.
- Construct a projection onto this plane of the center of the sphere, and then the circle of the intersection of the sphere and the plane.
- Solve the problem of having a common point for a triangle and a circle on a plane.
To simplify the calculation, it is recommended to perform a rotation about the center of the sphere so that the plane of the triangle is perpendicular to one of the coordinate lines.