makeSphericalSection

Create a binary map of a sphere segment within a 3D grid.

Syntax

ss = makeSphericalSection(radius, height, width, plot_section)
ss = makeSphericalSection(radius, height, [], plot_section)
ss = makeSphericalSection(radius, height, width, plot_section, binary)
ss = makeSphericalSection(radius, height, [], [] binary)

[ss, dist_map] = makeSphericalSection(radius, height, width)
[ss, dist_map] = makeSphericalSection(radius, height, [], plot_section)
[ss, dist_map] = makeSphericalSection(radius, height, width, plot_section)
[ss, dist_map] = makeSphericalSection(radius, height, width, plot_section, binary)
[ss, dist_map] = makeSphericalSection(radius, height, [], [] binary)

Description

makeSphericalSection creates a binary map of a section of a spherical surface within a three-dimensional matrix. The sphere is created using an extension of the midpoint circle algorithm. A single grid point is taken as the sphere center so the total diameter will always be an odd number of grid points. The sphere is then truncated based on the values for height and width (a diagram of the input sizes is given below). The face of the spherical section faces in the positive x-direction and the optional width parameter truncates the size in the y-direction. If the optional input parameter binary is set to false (the default), the section map is returned as a double precision matrix. If it is set to true, the map is returned as a logical matrix. The average distance between each grid point in the spherical section and its contiguous neighbours can also be returned. This is given as a ratio compared to the average neighbour distance for a flat surface.

Examples

makeSphericalSection(25, 6, 15, true); makeSphericalSection(50, 20, [], true); 