

Here is the images of a rubik's cube which i used as a sample. I exhausted points in between the grids of the cube for the upper face because it is the only part of the image with an expected variation in depth.
The value of f=14mm and b=10mm. For my case, the resulting image is just the upper face inverted due to arrangement of points in the matrix used and data plotting order. The deeper part is the upper portion of the face.

The Code:
x1=[183 214 248 283 320 352 385; 182 214 248 283 320 352 386; 181 213 248 283 321 354 387; 180 212 247 283 321 355 389; 179 211 247 283 322 356 391; 178 210 247 283 323 358 393; 176 209 247 283 323 358 395];
x2=[144 174 209 243 280 313 346; 143 173 209 243 280 313 347; 141 172 209 244 280 314 349; 140 171 208 244 281 315 350; 137 169 208 244 281 316 352; 135 167 207 244 282 317 353; 133 165 206 243 281 318 353];
f=14.;
b=10,;
z=[];
z=(b*f)./(x1-x2);
n = 7 // a regular grid with n x n interpolation points
// will be used
x = linspace(0,1,n); y = x;
//z = cos(x')*cos(y);z = cos(x')*cos(y);
C = splin2d(x, y, z, "periodic");
m = 10; // discretisation parameter of the evaluation grid
xx = linspace(0,1,m); yy = xx;
[XX,YY] = ndgrid(xx,yy);
zz = interp2d(XX,YY, x, y, C);
emax = max(abs(zz - cos(xx')*cos(yy)));
xbasc()
plot3d(xx, yy, zz);//, flag=[2 4 4])
[X,Y] = ndgrid(x,y);
param3d1(X,Y,list(z,-9*ones(1,n)), flag=[0 0])
str = msprintf(" with %d x %d interpolation points. ermax = %g",n,n,emax);
//xtitle("spline interpolation of cos(x)cos(y)"+str)n
No comments:
Post a Comment