Catmull–Clark subdivision surface: Difference between revisions

→‎{{header|Mathematica}}: added images illustrating the resulting impilmentation
(→‎{{header|Mathematica}}: Replaced code with more new more readable version.)
(→‎{{header|Mathematica}}: added images illustrating the resulting impilmentation)
Line 256:
Graphics3D[(Polygon[iteration[[1]][[#]]]&/@iteration[[2]])]
]/@NestList[CatMullClark,{points,faces},3]//GraphicsRow</lang>
[[File:CAM noholes 1.png]]
 
For a surface with holes the resulting iterative subdivision will be:
<lang Mathematica>faces = Delete[faces, 6];
Function[iteration, Graphics3D[
(Polygon[iteration[[1]][[#]]] & /@ iteration[[2]])
]] /@ NestList[CatMullClark, {points, faces}, 3] // GraphicsRow</lang>
[[File:CAM holes 1.png]]
 
This code was written in Mathematica 8.
Anonymous user