40 #include "glimports.h"
45 #include "nurbsconsts.h"
54 Mapdesc::calcPartialVelocity (
61 REAL tmp[MAXORDER][MAXCOORDS];
64 assert( ncols <= MAXORDER );
68 for( j=0; j != ncols; j++ )
69 for( k=0; k != inhcoords; k++ )
70 tmp[j][k] = p[j*stride + k];
72 for( t=0; t != partial; t++ )
73 for( j=0; j != ncols-t-1; j++ )
74 for( k=0; k != inhcoords; k++ )
75 tmp[j][k] = tmp[j+1][k] - tmp[j][k];
78 for( j=0; j != ncols-partial; j++ ) {
80 for( k=0; k != inhcoords; k++ )
81 mag[j] += tmp[j][k] * tmp[j][k];
86 REAL invt = 1.0 / range;
87 for( t = ncols-1; t != ncols-1-partial; t-- )
92 for( j=0; j != ncols-partial; j++ )
93 if( mag[j] > max ) max = mag[j];
94 max = fac * sqrtf( (
float) max );
105 Mapdesc::calcPartialVelocity (
118 REAL tmp[MAXORDER][MAXORDER][MAXCOORDS];
119 REAL mag[MAXORDER][MAXORDER];
121 assert( nrows <= MAXORDER );
122 assert( ncols <= MAXORDER );
124 REAL *tp = &tmp[0][0][0];
125 REAL *mp = &mag[0][0];
126 const int istride =
sizeof( tmp[0]) /
sizeof( tmp[0][0][0] );
127 const int jstride =
sizeof( tmp[0][0]) /
sizeof( tmp[0][0][0] );
131 const int mistride =
sizeof( mag[0]) /
sizeof( mag[0][0] );
132 const int mjstride =
sizeof( mag[0][0]) /
sizeof( mag[0][0] );
133 const int idist = nrows * istride;
134 const int jdist = ncols * jstride;
138 const int id = idist - spartial * istride;
139 const int jd = jdist - tpartial * jstride;
145 REAL *til = tp + idist;
146 for( ; ti != til; ) {
149 REAL *tjl = ti + jdist;
150 for( ; tj != tjl; ) {
151 for(
int k=0; k != inhcoords; k++ ) {
164 REAL *til = tp + idist - istride;
165 const REAL *till = til - ( spartial * istride );
166 for( ; til != till; til -= istride )
167 for( REAL *ti = tp; ti != til; ti += istride )
168 for( REAL *tj = ti, *tjl = tj + jdist; tj != tjl; tj += jstride )
169 for(
int k=0; k != inhcoords; k++ )
170 tj[k] = tj[k+istride] - tj[k];
175 REAL *tjl = tp + jdist - jstride;
176 const REAL *tjll = tjl - ( tpartial * jstride );
177 for( ; tjl != tjll; tjl -= jstride )
178 for( REAL *tj = tp; tj != tjl; tj += jstride )
179 for( REAL *ti = tj, *til = ti +
id; ti != til; ti += istride )
180 for(
int k=0; k != inhcoords; k++ )
181 ti[k] = ti[k+jstride] - ti[k];
188 memset( (
void *) mp, 0,
sizeof( mag ) );
189 for( REAL *ti = tp, *mi = mp, *til = tp +
id; ti != til; ti += istride, mi += mistride )
190 for( REAL *tj = ti, *mj = mi, *tjl = ti + jd; tj != tjl; tj += jstride, mj += mjstride ) {
191 for(
int k=0; k != inhcoords; k++ )
192 *mj += tj[k] * tj[k];
193 if( *mj > max ) max = *mj;
203 REAL invs = 1.0 / srange;
204 REAL invt = 1.0 / trange;
205 for(
int s = nrows-1, slast = s-spartial; s != slast; s-- )
207 for(
int t = ncols-1, tlast = t-tpartial; t != tlast; t-- )
215 for( i=0; i != nrows-spartial; i++ ) {
217 if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
219 j = ncols-tpartial-1;
220 if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
222 dist[0] = fac * sqrtf( dist[0] );
223 dist[1] = fac * sqrtf( dist[1] );
224 }
else if( side == 1 ) {
228 for( j=0; j != ncols-tpartial; j++ ) {
230 if( mag[i][j] > dist[0] ) dist[0] = mag[i][j];
232 i = nrows-spartial-1;
233 if( mag[i][j] > dist[1] ) dist[1] = mag[i][j];
235 dist[0] = fac * sqrtf( dist[0] );
236 dist[1] = fac * sqrtf( dist[1] );
239 max = fac * sqrtf( (
float) max );