tag:blogger.com,1999:blog-6171601131649660225.post4645033698950211228..comments2023-11-02T05:57:31.121-04:00Comments on cusack lab computing: Poisson disc in MatlabRhodriCusackhttp://www.blogger.com/profile/07602242092066277136noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6171601131649660225.post-55364361164770832532014-09-15T20:35:40.952-04:002014-09-15T20:35:40.952-04:00Hello,
In your 3D implementation of the Poisson di...Hello,<br />In your 3D implementation of the Poisson disk sampling, when generating a new random point around a given point, you will have to use the following line<br />[x y z]=sph2cart(2*pi*rand(1),pi/2 - (pi*rand(1)),min_dist*(rand(1)+1));<br />instead of <br />[x y z]=sph2cart(2*pi*rand(1),pi*rand(1),min_dist*(rand(1)+1));<br />This is because matlab measures phi from the XY plane towards positive Z-axis. In the algortihm used in sph2cart, Z = r*sin(phi) instead of the usual convention of Z = r*cos(phi) which is what your original code is based on, that is, measure phi from the Z-axis towards the XY plane.<br />Your original code ends up generating points only in the positive Z-axis quadrants for any given point.Scarecrowhttps://www.blogger.com/profile/15962407167676228366noreply@blogger.com