← 返回 tesla 的题目列表NumPy Point-to-Plane Distance and Robust Plane Fitting
类型:qbank
Given 3D points and a plane represented by `a*x + b*y + c*z + d = 0`, compute every point's distance to the plane in NumPy. Then estimate the dominant plane when roughly 70% of the points lie on it and return the points whose distances exceed a supplied threshold.
Requirements
Use NumPy throughout the round.
Part 1: accept a list of 3D points and a plane represented by a*x + b*y + c*z + d = 0; compute the distance from each point to that plane.
Part 2: accept another list of 3D points where about 70% lie on one plane and the remaining 30% belong to other objects or noise.
Estimate the dominant plane and identify every point whose distance from it exceeds a provided threshold.
Notes
For points P and plane coefficients n = [a, b, c], compute distances as abs(P @ n + d) / ||n||. Reject a coefficient vector whose norm is zero or numerically negligible.
Fit a plane without choosing a dependent coordinate: center the candidate inlier points, run SVD on the centered N x 3 matrix, take the right-singular vector for the smallest singular value as the unit normal, and set d = -centroid @ normal. This total-least-squares form also handles vertical and near-vertical planes.
With roughly 30% outliers, ordinary least squares over all points can be pulled away from the dominant plane. A robust implementation can repeatedly sample three non-collinear points, score the resulting plane by the supplied distance threshold, retain the model with the largest inlier set, and refit that set with SVD. Reject degenerate samples whose cross-product norm is near zero.
If the interviewer instead requests iterative trimming, make the contract explicit: refit with SVD, discard a stated fraction of the farthest residuals, and stop at a target retained fraction, when the inlier mask no longer changes, or after a fixed iteration cap. Return the final threshold mask rather than treating every trimmed point as an outlier.
Preparation
Implement a vectorized point-to-plane distance function over a batch of 3D points, including checks for invalid plane coefficients.
Build a synthetic point-cloud drill with a dominant plane plus outliers, then practice fitting the plane and returning a thresholded outlier mask using only NumPy.
Rehearse the NumPy operations needed for array shaping, regression, distance computation, sorting, and boolean masking without consulting API documentation.