[f949a5]: / theonewith_voxels.m

Download this file

45 lines (36 with data), 940 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
clear all; close all; clc;
gridesize=11;
% numbers are arbitrary
cube=zeros(11,11,11);
cube(3:9,3:9,3:9)=5; % Create a cube inside the region
% Boring: faces of the cube are a different color.
cube(3:9,3:9,3)=1;
cube(3:9,3:9,9)=1;
cube(3:9,3,3:9)=1;
cube(3:9,9,3:9)=1;
cube(3,3:9,3:9)=2;
cube(9,3:9,3:9)=1;
H=vol3d('Cdata',cube,'alpha',cube/5) %what is alpha?
figure;
[vol_handle]=VoxelPlotter(cube,0.5); %size of each voxel
view(3);
daspect([1,1,1]);
set(gca,'xlim',[0 gridesize], 'ylim',[0 gridesize], 'zlim',[0 gridesize]);
xlabel('X');ylabel('Y');zlabel('Z');
%figure;
%plot3(cube(:,:,1),cube(:,1,:));
%connects surfaces with specified value
figure;
x = 1:11;
y = 1:11;
z = 1:11;
v = cube;
alpha=isosurface(x,y,z,v,1);
p = patch(isosurface(x,y,z,v,5));
isonormals(x,y,z,v,p)
p.FaceColor = 'red';
p.EdgeColor = 'none';
daspect([1,1,1])
view(3); axis tight
camlight
lighting gouraud