# Spatial Data-Based Automatic and Quantitative Approach in Analyzing Maintenance Reachability
## 3 Materials and Methods
### Intersection Detection-Based Spatial Relationship Judgment between Arm and Product  
#### 3.3.1 Application of Typical Intersection Detection Methods Illustration  
According to the simplified models, one side of the intersection detection is the line segment and the other side covers five categories, namely, the bounding sphere, bounding box, cylinder, capsule, and triangle patch. Detailed descriptions of the five intersection detection processes are provided next. (1) Intersection detection of a line segment and a sphere  
The intersection detection of a line segment and a sphere is relatively simple, that is, comparing distance \(d\) from the center of the sphere to the line segment and the radius \(R\) of the sphere. As shown in Figure 5, if \(d>R\), then the line segment AB does not intersect with the sphere, and if \(d<R\), then the line segment AB intersects with the sphere. (2) Intersection of a line segment and an oriented bounding box (OBB)  
The intersection of a line segment and an OBB is detected by the separating axis theory. If a hyperplane \(P\) exists, such that the line segment and the OBB are on both sides of the hyperplane, then the line segment does not intersect with the OBB, otherwise it intersects. As shown in Figure 6, \(r_{b}\) is the projection radius of the OBB on vector \(v\), \(r_{s}\) is the projection radius of line segment AB on vector \(v\), and \(d\) is the projected length of the distance between the center point of the OBB and the midpoint of line segment AB on vector \(v\). If \(r_{b}+r_{s}<d\), then vector \(v\) is a separating axis of line segment AB and the OBB, and plane \(P\) is a hyperplane, line-segment AB and the OBB are on both sides of plane \(P\);  
Figure 5: Diagram of the Intersection Detection of a Line Segment and a Sphere. Figure 6: Diagram of the Intersection Detection of a Line Segment and an OBB. If \(r_{b}+r_{s}>d\), then vector \(v\) is not a separating axis of line segment AB and the OBB, and plane \(P\) is not a hyperplane, line segment AB and the OBB are not on both sides of plane \(P\). The detection between the line segment and the OBB needs to be tested for six axes, which are three face normal of the OBB and three cross-product vectors of the three face normal and direction vector of line segment AB. As long as one axis is the separate axis, line segment AB does not intersect with the OBB, otherwise line segment AB intersects with the OBB. (3) Intersection of a line segment and a cylinder  
Aside from the two intersection detection processes described above, the detection between the line segment and the cylinder is complex. The intersection between the line segment and the cylinder is detected by the method of finding the intersection point. If line segment AB does not have an intersection with the cylinder, then the line segment does not intersect with the cylinder, otherwise it intersects. Figure 7 shows the judgment process. First, whether the line where line segment AB is located intersects with the plane where the upper surface of the cylinder is located should be determined. If it intersects and the intersection point is in the line segment and the upper surface of the cylinder, then the line segment intersects with the cylinder. Otherwise, whether the line where line segment AB is located intersects with the surface where the lower surface of the cylinder is located should be determined. If it intersects and the intersection point is in the line segment and the lower surface of the cylinder, then the line segment intersects with the cylinder. Otherwise, whether the line where line segment AB is located intersects with the surface where the side surface of the cylinder is located should be determined. If it intersects and the intersection point is in the line segment and the side surface of the cylinder, then the line segment intersects with the cylinder. Otherwise, whether all line segments are inside the cylinder should be determined by selecting an end point for verification.