public Vector3?SegmentIntersectionIndex(Vector3 A, Vector3 B, int index) { Vector3 fenceA = this.path[index]; Vector3 fenceB = this.path[(index + 1) % this.path.Count]; return(SegmentMath.SegmentSegmentIntersection(A, B, fenceA, fenceB)); }
public static Vector3?SegmentPathIntersection(Vector3 A, Vector3 B, List <Vector3> path, bool closePath = true) { int iMax = path.Count - 1; if (closePath) { iMax += 1; } for (int i = 0; i < iMax; i++) { Vector3 C = path[i]; Vector3 D = path[(i + 1) % path.Count]; Vector3?intersection = SegmentMath.SegmentSegmentIntersection(A, B, C, D); if (intersection != null) { return(intersection); } } return(null); }