Mercurial > hg > octave-lyh
comparison scripts/plot/shrinkfaces.m @ 14872:c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
* gradient.m, interp1q.m, rat.m, tsearchn.m, image.m, imwrite.m, area.m,
contourc.m, hist.m, isocolors.m, isonormals.m, meshz.m, print.m, __bar__.m,
__go_draw_axes__.m, __interp_cube__.m, __marching_cube__.m, __patch__.m,
__print_parse_opts__.m, __quiver__.m, rose.m, shrinkfaces.m, stairs.m,
surfnorm.m, tetramesh.m, text.m, deconv.m, spline.m, intersect.m, setdiff.m,
setxor.m, union.m, periodogram.m, pcg.m, perms.m: Replace size (x,1) with
rows (x) and size(x,2) with columns(x).
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 17 Jul 2012 13:34:19 -0700 |
parents | 1804d5422f61 |
children | f3b5cadfd6d5 |
comparison
equal
deleted
inserted
replaced
14871:26c4ca9782b0 | 14872:c2dbdeaa25df |
---|---|
102 | 102 |
103 if (! isscalar (sf) || sf <= 0) | 103 if (! isscalar (sf) || sf <= 0) |
104 error ("shrinkfaces: scale factor must be a positive scalar") | 104 error ("shrinkfaces: scale factor must be a positive scalar") |
105 endif | 105 endif |
106 | 106 |
107 n = size (vertices, 2); | 107 n = columns (vertices); |
108 if (n < 2 || n > 3) | 108 if (n < 2 || n > 3) |
109 error ("shrinkfaces: only 2D and 3D patches are supported") | 109 error ("shrinkfaces: only 2D and 3D patches are supported") |
110 endif | 110 endif |
111 | 111 |
112 m = size (faces, 2); | 112 m = columns (faces); |
113 if (m < 3) | 113 if (m < 3) |
114 error ("shrinkfaces: faces must consist of at least 3 vertices") | 114 error ("shrinkfaces: faces must consist of at least 3 vertices") |
115 endif | 115 endif |
116 | 116 |
117 v = vertices(faces'(:), :); | 117 v = vertices(faces'(:), :); |
118 if (isempty (colors) || size (colors, 1) == size (faces, 1)) | 118 if (isempty (colors) || rows (colors) == rows (faces)) |
119 c = colors; | 119 c = colors; |
120 elseif (size (colors, 1) == size (vertices, 1)) | 120 elseif (rows (colors) == rows (vertices)) |
121 c = colors(faces'(:), :); | 121 c = colors(faces'(:), :); |
122 else | 122 else |
123 ## Discard inconsistent color data. | 123 ## Discard inconsistent color data. |
124 c = []; | 124 c = []; |
125 endif | 125 endif |
126 sv = size (v, 1); | 126 sv = rows (v); |
127 ## we have to deal with a probably very large number of vertices, so | 127 ## we have to deal with a probably very large number of vertices, so |
128 ## use sparse we use as midpoint (1/m, ..., 1/m) in generalized | 128 ## use sparse we use as midpoint (1/m, ..., 1/m) in generalized |
129 ## barycentric coordinates. | 129 ## barycentric coordinates. |
130 midpoints = full (kron ( speye (sv / m), ones (m, m) / m) * sparse (v)); | 130 midpoints = full (kron ( speye (sv / m), ones (m, m) / m) * sparse (v)); |
131 v = sqrt (sf) * (v - midpoints) + midpoints; | 131 v = sqrt (sf) * (v - midpoints) + midpoints; |