Hello, I am trying to generate randomly placed spheres inside of a defined hemisphere domain. I would like the spheres to be generated in a spherical pattern. Would I need to use spherical coordinates converted to euclidean coordinates with a scatter3 'filled' plot for this part? Next, I want to calculate the distance between a sphere placed at the origin of the domain and the new spheres. From my understanding that would require me to calculate the distance between 2 surfaces or a surface and multiple points, but from my research I have not seen any ways to do this in the documentation or answers pages. I have attached my code below that defines the domain and sets the origin hemisphere. Any help is greatly appreciated.
% Create Hemisphere Domain
[x_dom,y_dom,z_dom] = sphere(80); %Create Sphere
x_dom = x_dom(41:end,:); % Keep top 41 x points
y_dom = y_dom(41:end,:); % Keep top 41 y points
z_dom = z_dom(41:end,:); % Keep top 41 z points
hemisphere_radius = 80;figure();Hemi_sf = surf(hemisphere_radius.*x_dom,hemisphere_radius.*y_dom,hemisphere_radius.*z_dom, 'FaceColor','#4DBEEE','EdgeColor', 'none');alpha 0.2x_ax_lab = xlabel('x axis', 'Color', '#4DBEEE');y_ax_lab = ylabel('y axis', 'Color', '#4DBEEE');z_ax_lab = zlabel('z axis', 'Color', '#4DBEEE');% Plot Hemisphere Lower Boundary Circular Plane
x_c = 0;y_c = 0;z_c = 0;radii_plane = 80;radii_vein = 4;radii_node = 4;center_plane = [x_c, y_c]; % center point of circular plane
viscircles(center_plane, radii_plane, 'color', '#77AC30'); hold on%%
% Place Center Sphere
[x_c,y_c,z_c] = sphere();x_c = x_c(11:end,:); % Keep top 11 x points
y_c = y_c(11:end,:); % Keep top 11 y points
z_c = z_c(11:end,:); % Keep top 11 z points
center_root = surf(radii_vein.*x_c,radii_vein.*y_c,radii_vein.*z_c, 'FaceColor', 'k');
Best Answer