matlab - Find Overlapping Region between 3-Dimensional Shapes -
i'm plotting 2 separate 3-dimensional amorphous blobs overlap each other. have created blobs deforming unit circle (as can see in code provided below). question is: there easy way isolate overlapping region? need isolate overlapping region , color differently (as in turn region green, example) show overlap is. actual program has many shapes overlap, sake of simplicity, have produced following code illustrate trying do:
% create sphere 100 points n = 100; % sphere grid points [x,y,z] = sphere(n); % x,y,z coordinates sphere num=size(x,1)*size(x,2); % total amount of x-coordinates (m*n) % loop through every x-coordinate , apply scaling if applicable k=1:num % loop through every coordinate value=x(k); % store original value of x(k) value if value<0 % compare value 0 x(k)=0.3*value; % if < 0, scale value end end % loop through every z-coordinate , apply scaling if applicable k=1:num % loop through every coordinate value=z(k); % store original value of x(k) value if value>0 % compare value 0 z(k)=0.3*value; % if < 0, scale value end end mesh(x,y,z,'facecolor','y','edgecolor','y','facealpha',... 0.2,'edgealpha',0.2); hold on mesh(-1*(x-1),y,z,'facecolor','r','edgecolor','r','facealpha',... 0.2,'edgealpha',0.2); hold off axis equal
i'm not necessarliy looking code, effective algorithm or process achieve desired results need adapt result more sophisticated program have.
maintain array (n-dimensional) of integers, draw objects, increment each corresponding point in array. when done, loop through array, , each element > 1 has overlap between 2 or more objects, use array coordinate color objects based on number of overlaps.
Comments
Post a Comment