# computational geometry – Mahalanobis distance of point to plane algorithm

I am trying to understand the Mahalanobis distance of a point from the plane given by this paper. The algorithm is given below:

1. Calculate covariance of point $$S_{uu}$$
2. Apply a whitening transform to the covariance matrix using SVD where $$S_{uu} = RVR^T$$. $$R$$ is the rotation matrix and $$V$$ is the scale $$V = diag(a^2, b^2, c^2)$$
3. The output is transformed into 3 homogenous 4×4 matrices

$$Rh = begin{bmatrix} R & 0 \ 0^T & 1 end{bmatrix}, Th = begin{bmatrix} I & 0 \ -u^T & 1 end{bmatrix}, Ah = diag(a,b,c,1)$$

where u is the centroid of the plane

4.The transformed plane is given by $$q = Ah*Rh*Th*p$$ where p is the planar parameters

My first question is regarding the whitening transform. I am not sure how it is being derived (its not given in the paper). If anyone can provide an intuitive explanation, that would be great.

My second question is – I simulated a plane with planar parameters (0, 0, 1) and points on the plane with std error of 0.02. We can recover the planar parameters using svd. Now, when I run the algorithm to get the transformed plane using the following code:

``````# whitening transform of point covariance
cov_pts = np.cov(pts.transpose())
r, v, rt = np.linalg.svd(cov_pts)
abc = np.sqrt(v)
ah = np.diag(v=np.concatenate((abc, np.array((1)))))
rh = np.zeros((4, 4))
rh(0:3, 0:3) = r
rh(3, 3) = 1
th = np.eye(4)
th(3, 0:3) = -center
transformed_plane_fit = np.dot(np.matmul(np.matmul(ah, rh), th),
np.concatenate((plane_fit, np.array((1)))))
``````

the values I get for transformed planar fit is array((-2.99291157e-02, -7.31159923e-04, -1.97310249e-02, 9.11576594e-01)) which doesn’t seem to correspond to the planar parameters. What can be the reason for the discrepancy?

Posted on Categories Articles