Compute Point-to-Plane Distance and Fit a Robust Plane
Use NumPy-style vectorized operations to solve both parts of this 3D geometry exercise.
Constraints & Assumptions
-
Points are supplied as a finite floating-point array with shape (n, 3).
-
A plane is represented by coefficients (a, b, c, d) for ax + by + cz + d = 0.
-
In Part 2, approximately 70% of the points come from one physical plane and the rest are other objects or noise.
-
The distance threshold is provided in the same units as the coordinates.
-
Degenerate inputs must be detected rather than silently producing NaN values.
Clarifying Questions to Ask
-
Is the threshold an absolute geometric distance?
-
What numerical tolerance should define a degenerate plane or collinear sample?
-
Must the returned normal have a canonical sign and unit length?
-
Is randomized fitting acceptable, and must runs be reproducible?
Part 1: Vectorized Distances
Given points and plane coefficients, return the unsigned perpendicular distance from every point to the plane without a Python loop over points.
Hints
-
Express the numerator for all points as one matrix operation.
-
Determine which property of the coefficient vector makes the result invariant to rescaling the equation.
What This Part Should Cover
-
Correct dimensions and normalization
-
Vectorized computation
-
Degenerate-normal handling
Part 2: Robust Plane and Outliers
Estimate the dominant plane despite roughly 30% outliers, then return the indices whose distance from the final plane exceeds the threshold. Describe a deterministic or seeded implementation and how you refine the estimate.
Hints
-
A small subset can propose a hypothesis.
-
Separate hypothesis selection from final parameter estimation.
What This Part Should Cover
-
Robustness to a large outlier fraction
-
A reproducible model-selection rule
-
Refinement and outlier classification
-
Numerical edge cases
What a Strong Answer Covers
-
A correct geometric derivation
-
Careful NumPy shapes and floating-point checks
-
A robust estimator with explicit scoring and tie-breaking
-
Complexity, reproducibility, and failure behavior
Follow-up Questions
-
How many random hypotheses are needed for a desired success probability?
-
How would heteroscedastic sensor noise change the inlier rule?
-
How would you fit several planes rather than only the dominant one?