File:Five point stencil illustration.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(2,192 × 2,408 pixels, file size: 106 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents
Description Illustration of five-point stencil in one and two dimensions.
Source Own work
Author Oleg Alexandrov (talk)
 
This diagram was created with MATLAB.
Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Source code (MATLAB)[edit]

 

% Illustration of five-point stencil in one and two dimensions.

function main ()

   figure(1); clf; hold on; axis equal; axis off;
   
% make nice lightning
   camlight right; lighting phong;

% draw both stencils on the same picture, with the second one
% shifted down
   shift=[0, -13];
   for type=1:2
      draw_stencil(type, shift(type))
   end
   
% save to disk. High resolution is very important here, that's why r400
print('-dpng',  '-r400', 'Five_point_stencil_illustration.png', '-opengl');
		 

function draw_stencil (type, shift)

% the "type" argument above determines if the stencil is 1D or 2D

   % N= number of points in each surface. The more, the smoother the surfaces are.
   N = 100; 
   
   h=5; % grid size

   if type == 1
	  % 1D
      Stencilx=[-2*h, -h, 0, h, 2*h];
      Stencily=[0,     0, 0, 0, 0];
   else
	  % 2D
      Stencilx=[-h, 0, h, 0, 0];
      Stencily=[0,  0, 0, -h, h];
   end
   
% draw the points in the stencil as spheres
   [X, Y, Z] =sphere(N);
   for i=1:length(Stencilx)
      
% draw the spheres
      H=surf(X+Stencilx(i), Y+Stencily(i)+shift, Z, 'FaceColor', 'blue', ...
			 'EdgeColor','none', 'AmbientStrength', 0.3, ...
	  'SpecularStrength', 1, 'DiffuseStrength', 0.8);
      
% make the center of the stencil red
      if Stencilx(i) == 0 & Stencily(i) == 0
	 set(H, 'FaceColor', 'red');
      end
      
   end
   
% create a cylinder which connects the points in the stencil
   [X, Y, Z] = cylinder([1, 1], N);
   L=4*h; rad=0.3;
   X=rad*X; Y=rad*Y; Z=L*Z-L/2;
   Tmp = Z; Z=X; X = Tmp;
   
% draw the cylinders, depending on type. A very convoluted code
   for k=1:2

      if type == 1 & k == 2
		 break;
      end
	  
      if type == 2
		 
		 if k == 1
			X = X/2;
		 else 
			Tmp = X; X = Y; Y = Tmp;
		 end;
		 
      end
      
      gray = 0.5*[1, 1, 1]; 
      H=surf(X, Y+shift, Z, 'FaceColor', gray, 'EdgeColor','none', ...
			 'AmbientStrength', 0.7, 'SpecularStrength', 1, 'DiffuseStrength', 0.8);
      
      
   end
This math image could be re-created using vector graphics as an SVG file. This has several advantages; see Commons:Media for cleanup for more information. If an SVG form of this image is available, please upload it and afterwards replace this template with {{vector version available|new image name}}.


It is recommended to name the SVG file “Five point stencil illustration.svg”—then the template Vector version available (or Vva) does not need the new image name parameter.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current03:36, 2 May 2007Thumbnail for version as of 03:36, 2 May 20072,192 × 2,408 (106 KB)Oleg Alexandrov (talk | contribs){{Information |Description= |Source= |Date= |Author= }}
17:01, 1 May 2007Thumbnail for version as of 17:01, 1 May 20072,196 × 1,988 (93 KB)Oleg Alexandrov (talk | contribs){{Information |Description= |Source= |Date= |Author= }} {{PD-self}} Category:Numerical analysis
16:59, 1 May 2007Thumbnail for version as of 16:59, 1 May 20073,200 × 2,400 (109 KB)Oleg Alexandrov (talk | contribs){{Information |Description= |Source= |Date= |Author= }} {{PD-self}} Category:Numerical analysis
16:50, 1 May 2007Thumbnail for version as of 16:50, 1 May 20072,116 × 1,952 (97 KB)Oleg Alexandrov (talk | contribs){{Information |Description= |Source= |Date= |Author= }} {{PD-self}} Category:Numerical analysis

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: