Talk:Catmull–Clark subdivision surface: Difference between revisions

From Rosetta Code
Content deleted Content added
proposition of an image
Looks nice, but some suggested tweaks.
Line 84: Line 84:
: I propose this image to illustrate the article:
: I propose this image to illustrate the article:
[[Image:Catmull_subsurf.png‎]]
[[Image:Catmull_subsurf.png‎]]
:: Looks good, but I would suggest breaking it into three images and losing the built-in descriptor lines. I would also suggest stretching the contrast ratio such that it's white on black, rather than light-gray on dark-gray. --[[User:Short Circuit|Michael Mol]] 08:08, 9 January 2010 (UTC)

Revision as of 08:08, 9 January 2010

What's the input for the function? Example input/output?

typical 3D datas are formated like this: an array of vertex points first (x,y,z) 3D coordinates with type (float, float, float), they are indexed from 0 to (n - 1), then a list (or array) of faces, a triangle face is specified with 3 ints, and a quad face with 4 ints, the ints are the indexes in the first array. This data model is most often used because vertices belongs to several faces, so there are no duplication of the coordinates with this model.
here are below a typical input and output for the Catmull-Clark subdivision surface algorythm, the input is a simple cube:
input_points = [
  (-1.0,  1.0,  1.0);
  (-1.0, -1.0,  1.0);
  ( 1.0, -1.0,  1.0);
  ( 1.0,  1.0,  1.0);
  ( 1.0, -1.0, -1.0);
  ( 1.0,  1.0, -1.0);
  (-1.0, -1.0, -1.0);
  (-1.0,  1.0, -1.0);
]

input_faces = [
  (0, 1, 2, 3);
  (3, 2, 4, 5);
  (5, 4, 6, 7);
  (7, 0, 3, 5);
  (7, 6, 1, 0);
  (6, 1, 2, 4);
]

# below after one iteration:

output_points = [
  (-0.555556,  0.555556,  0.555556);
  (-0.555556, -0.555556,  0.555556);
  ( 0.555556, -0.555556,  0.555556);
  ( 0.555556,  0.555556,  0.555556);
  ( 0.555556, -0.555556, -0.555556);
  ( 0.555556,  0.555556, -0.555556);
  (-0.555556, -0.555556, -0.555556);
  (-0.555556,  0.555556, -0.555556);
  ( 0.000000,  0.000000,  1.000000);
  (-0.666667,  0.000000,  0.666667);
  ( 0.000000, -0.666667,  0.666667);
  ( 0.666667,  0.000000,  0.666667);
  ( 0.000000,  0.666667,  0.666667);
  ( 1.000000,  0.000000,  0.000000);
  ( 0.666667, -0.666667,  0.000000);
  ( 0.666667,  0.000000, -0.666667);
  ( 0.666667,  0.666667,  0.000000);
  ( 0.000000,  0.000000, -1.000000);
  ( 0.000000, -0.666667, -0.666667);
  (-0.666667,  0.000000, -0.666667);
  ( 0.000000,  0.666667, -0.666667);
  ( 0.000000,  1.000000,  0.000000);
  (-0.666667,  0.666667,  0.000000);
  (-1.000000,  0.000000,  0.000000);
  (-0.666667, -0.666667,  0.000000);
  ( 0.000000, -1.000000,  0.000000);
]

output_faces = [
  ( 0,  9,  8, 12);
  ( 1, 10,  8,  9);
  ( 2, 11,  8, 10);
  ( 3, 12,  8, 11);
  ( 3, 11, 13, 16);
  ( 2, 14, 13, 11);
  ( 4, 15, 13, 14);
  ( 5, 16, 13, 15);
  ( 5, 15, 17, 20);
  ( 4, 18, 17, 15);
  ( 6, 19, 17, 18);
  ( 7, 20, 17, 19);
  ( 7, 22, 21, 20);
  ( 0, 12, 21, 22);
  ( 3, 16, 21, 12);
  ( 5, 20, 21, 16);
  ( 7, 19, 23, 22);
  ( 6, 24, 23, 19);
  ( 1,  9, 23, 24);
  ( 0, 22, 23,  9);
  ( 6, 24, 25, 18);
  ( 1, 10, 25, 24);
  ( 2, 14, 25, 10);
  ( 4, 18, 25, 14);
]
I propose this image to illustrate the article:

Looks good, but I would suggest breaking it into three images and losing the built-in descriptor lines. I would also suggest stretching the contrast ratio such that it's white on black, rather than light-gray on dark-gray. --Michael Mol 08:08, 9 January 2010 (UTC)