Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % create cube that spans points from [1,1,1] to [3,3,3]
- vertices = [0 0 0; 1 0 0; 1 0 1; 0 0 1; 0 1 0; 1 1 0; 1 1 1; 0 1 1];
- vertices = 2*vertices;
- vertices = vertices + ones(size(vertices));
- % faces for cube
- faces = [1 2 3 4; 2 6 7 3; 6 5 8 7; 5 1 4 8; 4 3 7 8; 1 5 6 2];
- % display cube
- fv.faces = faces;
- fv.vertices = vertices;
- figure, patch(fv, ...
- 'FaceColor','blue','EdgeColor','Black');
- view([14,60]); axis vis3d tight
- % voxelise cube
- cubeVolume = VOXELISE(4,4,4,fv);
- disp(['cubeVolume(2,2,2) should have value 1, but is ' num2str(cubeVolume(2,2,2))]);
- % display voxelised cube with method provided in VOXELISE_example
- figure;
- subplot(1,3,1);
- imagesc(squeeze(sum(cubeVolume,1)));
- colormap(gray(256));
- xlabel('Z-direction');
- ylabel('Y-direction');
- axis equal tight
- subplot(1,3,2);
- imagesc(squeeze(sum(cubeVolume,2)));
- colormap(gray(256));
- xlabel('Z-direction');
- ylabel('X-direction');
- axis equal tight
- subplot(1,3,3);
- imagesc(squeeze(sum(cubeVolume,3)));
- colormap(gray(256));
- xlabel('Y-direction');
- ylabel('X-direction');
- axis equal tight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement