Quantcast
Channel: MATLAB Central Newsreader - tag:"patch"
Viewing all articles
Browse latest Browse all 25

Re: Plot a Cube

$
0
0
Hi Alex,

Small typo in the face ordering. I think

> face = [1 2 3 4;5 6 7 8;3 4 8 7;1 2 6 5;2 3 7 6;4 1 8 5];

should be

> face = [1 2 3 4;5 6 7 8;3 4 8 7;1 2 6 5;2 3 7 6;1 4 8 5];

John

"Alex V" <avarnau@purdue.edu> wrote in message <jnnnot$li2$1@newscl01ah.mathworks.com>...
> Just for info, another way to use patch to plot a cube is to define vertices and faces as follows:
>
> verts = ([0 0 0;0 1 0;1 1 0;1 0 0;0 0 1;0 1 1;1 1 1;1 0 1]-0.5).*sidelength;
> %this is of course the x,y,z coordinates of the unit cube's vertices, shifted to center on origin and multiplied by sidelength
>
> face = [1 2 3 4;5 6 7 8;3 4 8 7;1 2 6 5;2 3 7 6;4 1 8 5];
> %this is, less obviously, the order of connection of vertices for each face.
>
> h = patch('Faces',face,'Vertices',verts,'FaceColor','b','EdgeColor','w');
>
> this makes much more sense if you, again, draw a little 3-axes and draw this out manually

Viewing all articles
Browse latest Browse all 25

Trending Articles