I have a set of $N$ points in form of their $xyz$ coordinates. I am not using all of them due to high computation time. I am looking to find best plane fit to given set of points.
I used this as reference: Hugh transform on page 3, there's algorithm number 2 that interests me
I am calculating their Hough space coordinates using this formula:
$$p = x_n \cos(\theta)\sin(\phi) + y_n\sin(\phi)\sin (\theta) + z_n\cos(\phi),$$
wher $\phi \in [-90°, 90°]$, $\theta \in [0°, 360°]$.
This is where I am probably wrong:
So for each point I am calculating $180 × 360$ possible combinations of degrees in sin and cos. I defined a matrix that has $360$ rows and $180$ columns for each combination of $\phi$ and $\theta$. I increment cells in this matrix if threshold $p$ is less than $0.03$.
If this is incorrect please tell me what I am doing wrong there.
So in the end I have matrix of votes and highest numbers in matrix represents combination of $\phi$ and $\theta$ that are best solution for algorithm.
But what I need is classic plane formula:
$$Ax + By + Cz + D = 0.$$
How do I get that equation from $\phi$ and $\theta$ that I get from algorithm?