Software Listing of Author : "Kevin Moerman"
- image3Ddata
- License: Shareware
- Price:


This simple function creates a structure array containing coordinate and colour data for 3D images. The example below shows how the function allows one to use the patch function to plot the whole image or a selection of voxels in 3D. The CData is generated using the voxel intensities. N.B. The function has not been optimised for large images. Large images (function has been tested for images under 100x100x100) may produce memory problems. %% EXAMPLE M=rand(15,15,15); [IMAGE_3D_DATA]=image3Ddata(M); %Getting faces and vertices for full image voxel_no=1:1:numel(M); voxel_face_no=IMAGE_3D_DATA.voxel_patch_face_numbers(voxel_no,:); M_faces=IMAGE_3D_DATA.voxel_patch_faces(voxel_face_no,:); M_vertices=IMAGE_3D_DATA.corner_coordinates_columns_XYZ; %Getting faces and vertices for selection of voxels voxel_no2=M>0.95;...
- Publisher: Kevin Moerman
- Date Released: 07-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- ind2patch
- License: Freeware
- Price: 0.00


This function generates patch data (faces 'F', vertices 'V' and color data 'C') for 3D images. The patches are only generated for the voxels specified by the linear indices in 'IND'. The variable 'ptype' indicates the type of patch: 'v' Voxel (box) 'sx', 'sy', 'sz' Mid-voxel slice for x, y and z direction respectively EXAMPLE clear all; close all; clc; Simulating 3D image [X,Y,Z]=meshgrid(linspace(-4.77,4.77,75)); phi=(1+sqrt(5))/2; M=2 - (cos(X + phi*Y) + cos(X - phi*Y) + cos(Y + phi*Z) + cos(Y - phi*Z) + cos(Z - phi*X) + cos(Z + phi*X)); M=M./max(M(:)); %Normalise, not required figure;fig=gcf; clf(fig); colordef (fig, 'white'); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); set(fig,'Color',[1 1 1]); hold on;...
- Publisher: Kevin Moerman
- Date Released: 04-01-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- mesh2tri
- License: Shareware
- Price:


Converts a regular mesh defined by X,Y and Z into a regular triangulation. The output is patch data (triangles) in the faces 'F' and vertices 'V' format. The quadrilateral mesh faces are converted to triangles by splitting the faces into triangles according to the setting tri_type: tri_type ='f' -> forward slash division of quadrilateral tri_type ='b' -> back slash division of quadrilateral tri_type ='x' -> Cross division of quadrilateral The output coordinates "V" are in the form of V=[X(:),Y(:),Z(:)]; For forward and back slash subdivision no extra coordinates are introduced and therefore the original meshgrid formatted coordinates can still be used for plotting, see examples below. For cross division extra points are created at the centre of each quadrilateral face using the mean of the input coordinates. The extra coordinates are...
- Publisher: Kevin Moerman
- Date Released: 06-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- monte_carlo_spheregrid
- License: Shareware
- Price:


Simple example of the use of the code spheregrid.m. Finds the peak in the matlab example data PEAKS. Initially uses meshgrid to find a maximum then 'zooms in' and seeds points in a circle around the point found, it then find the maximum and continues the process.
- Publisher: Kevin Moerman
- Date Released: 03-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- platonic_solid
- License: Shareware
- Price:


function [V,F]=platonic_solid(n,r) Creates the PATCH data, the vertices (V) and faces (F) for a given platonic solid (according to "n" see below) with radius (r) n=1 -> Tetrahedron n=2 -> Cube n=3 -> Octahedron n=4 -> Icosahedron n=5 -> Dodecahedron %% Example clear all; close all; clc; r=1; figure;fig=gcf; clf(fig); colordef (fig, 'white'); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); set(fig,'Color',[1 1 1]); hold on; [V,F]=platonic_solid(1,r); subplot(2,3,1); patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off; [V,F]=platonic_solid(2,r); subplot(2,3,2); patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on;...
- Publisher: Kevin Moerman
- Date Released: 01-04-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- polyrevolve
- License: Shareware
- Price:


[X,Y,Z]=polyrevolve(x,z,n) This function revolves a 2D polygon around the Z-axis. It copies the 2D data points evenly around the axis and produces a 3D data set suitable for input to MESHGRID and GRIDDATA to create a 3D surface. Useful to convert 2D axisymmetric data to 3D surfaces for presentation and or analysis. The spacing from one revolved point to the next is defined by the parameter n. The required angular spacing (alpha) for each point is determined using the relationship n=2*r*sin(alpha). %% EXAMPLE: clear all; close all; clc; x=0:0.2:2*pi; z=sin(x+(pi/2)); revolve_res=0.2; [X,Y,Z]=polyrevolve(x,z,revolve_res); grid_res=0.05; [XI,YI] = meshgrid(min(min(X)):grid_res:max(max(X)),min(min(Y)):grid_res:max(max(Y))); ZI = griddata(X,Y,Z,XI,YI,'cubic'); figure; fig=gcf; clf(fig); units=get(fig,'units');...
- Publisher: Kevin Moerman
- Date Released: 20-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- quiver3Dpatch
- License: Shareware
- Price:


This function allows plotting of colored 3D arrows by generating patch data (faces 'F', vertices 'V' and color data 'C'). The patch data which allows plotting of 3D quiver arrows with specified (e.g. colormap driven) color. To save memory n arrows are created using only n*6 faces and n*7 vertices. The vector "a" defines arrow length scaling where a(1) is the smallest arrow length and a(2) the largest. Use the PATCH command to plot the arrows: [F,V,C]=quiver3Dpatch(x,y,z,ux,uy,uz,a) patch('Faces',F,'Vertices',V,'CData',C,'FaceColor','flat');
- Publisher: Kevin Moerman
- Date Released: 13-05-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- subtri
- License: Freeware
- Price: 0.00


[Fs,Vs]=subtri(F,V,n) Sub-triangulates the triangles defined by the patch format data F (faces) and V (vertices). Can be used to increase the density of triangulated data or to triangulate the icosahedron to create geodesic sphere triangulations with desired density. Creates n addition points on the edges of the initial triangles, thus it creates (n+1).^2 triangles per original triangle. No double points are introduced. EXAMPLE [X,Y] = meshgrid(linspace(-10,10,15)); Z = sinc(sqrt((X/pi).^2+(Y/pi).^2)); F = delaunay(X,Y); V=[X(:) Y(:) Z(:)]; C=mean(Z(F),2); n=2; [Fs,Vs]=subtri(F,V,n); Vs(:,3)=sinc(sqrt((Vs(:,1)/pi).^2+(Vs(:,2)/pi).^2)); Z=Vs(:,3);Cs=mean(Z(Fs),2); figure('units','normalized','Position',[0 0 1 1],'Color','w'); colordef('white');...
- Publisher: Kevin Moerman
- Date Released: 09-05-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
