annotate private/EDB1getedgepoints.m @ 18:2d5f50205527 jabuilder_int tip

Escape the trailing backslash as well
author Chris Cannam
date Tue, 30 Sep 2014 16:23:00 +0100
parents 90220f7249fc
children
rev   line source
tp@0 1 function [edgepointcoords,weightvec,edgenumberlist] = EDB1getedgepoints(edgestartcoords,edgeendcoords,edgelengths,nedgesubs,returnedgenumbers)
tp@0 2 % EDB1getedgepoints - Calculates a number of edge coordinates.
tp@0 3 %
tp@0 4 % Input parameters:
tp@0 5 % edgestartcoords Matrix, [nedges,3], of the startpoint coordinates of nedges edges.
tp@0 6 % edgeendcoords Matrix, [nedges,3], of the endpoint coordinates of nedges edges.
tp@0 7 % edgelengths List, [nedges,1], of edge lengths.
tp@0 8 % nedgesubs The desired number of subdivisions per edge.
tp@0 9 % returnedgenumbers (optional) If this optional parameter is given the
tp@0 10 % value 1, the output parameter edgenumberlist will be non-empty.
tp@0 11 %
tp@0 12 % NB! The input parameters edgestartcoords, edgeendcoords and edgelengths
tp@0 13 % should have been passed on directly from the eddata file.
tp@0 14 % The parameter nedgesubs should have been taken from the setup file.
tp@0 15 %
tp@0 16 % Output parameters:
tp@0 17 % edgepointcoords Matrix, [nedges*nedgesubs,3], of the midpoints
tp@0 18 % of the edge subdivision segments.
tp@0 19 % weightvec List, [nedges*nedgesubs,3], with the weights
tp@0 20 % (1,2,4,8,...) per edge subdivision segment.
tp@0 21 % edgenumberlist List, [nedges*nedgesubs,1], of which edge
tp@0 22 % number each subdivision segment originated from.
tp@0 23 % See also the input parameter returnedgenumbers.
tp@0 24 %
tp@0 25 % ----------------------------------------------------------------------------------------------
tp@0 26 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
tp@0 27 %
tp@0 28 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
tp@0 29 % it under the terms of the GNU General Public License as published by the Free Software
tp@0 30 % Foundation, either version 3 of the License, or (at your option) any later version.
tp@0 31 %
tp@0 32 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
tp@0 33 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
tp@0 34 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
tp@0 35 %
tp@0 36 % You should have received a copy of the GNU General Public License along with the
tp@0 37 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
tp@0 38 % ----------------------------------------------------------------------------------------------
tp@0 39 % Peter Svensson (svensson@iet.ntnu.no) 20030503
tp@0 40 %
tp@0 41 % [edgepointcoords,weightvec,edgenumberlist] = EDB1getedgepoints(edgestartcoords,edgeendcoords,edgelengths,nedgesubs,returnedgenumbers);
tp@0 42
tp@0 43 if nargin < 5
tp@0 44 returnedgenumbers = 0;
tp@0 45 end
tp@0 46
tp@0 47 [nedges,slask] = size(edgestartcoords);
tp@0 48
tp@0 49 if nedgesubs == 1
tp@0 50 edgepointcoords = (edgestartcoords+edgeendcoords)/2;
tp@0 51 weightvec = uint8(ones(nedges,1));
tp@0 52 if returnedgenumbers == 1
tp@0 53 if nedges < 256
tp@0 54 edgenumberlist = uint8([1:nedges]);
tp@0 55 elseif nedges < 65536
tp@0 56 edgenumberlist = uint16([1:nedges]);
tp@0 57 else
tp@0 58 edgenumberlist = uint32([1:nedges]);
tp@0 59 end
tp@0 60 else
tp@0 61 edgenumberlist = [];
tp@0 62 end
tp@0 63 return
tp@0 64 end
tp@0 65
tp@0 66 ntot = nedges*nedgesubs;
tp@0 67
tp@0 68 edgestart = zeros(ntot,3);
tp@0 69 edgeend = zeros(ntot,3);
tp@0 70
tp@0 71 onesvec1 = ones(nedgesubs,1);
tp@0 72 onesvec2 = ones(1,3);
tp@0 73 onesvec3 = ones(1,nedges);
tp@0 74
tp@0 75 %-------------------------------------------------
tp@0 76 % Start points
tp@0 77
tp@0 78 A = edgestartcoords(:,1).';
tp@0 79 edgestart(:,1) = reshape(A(onesvec1,:),ntot,1);
tp@0 80
tp@0 81 A = edgestartcoords(:,2).';
tp@0 82 edgestart(:,2) = reshape(A(onesvec1,:),ntot,1);
tp@0 83
tp@0 84 A = edgestartcoords(:,3).';
tp@0 85 edgestart(:,3) = reshape(A(onesvec1,:),ntot,1);
tp@0 86
tp@0 87 %-------------------------------------------------
tp@0 88 % End points
tp@0 89
tp@0 90 A = edgeendcoords(:,1).';
tp@0 91 edgeend(:,1) = reshape(A(onesvec1,:),ntot,1);
tp@0 92
tp@0 93 A = edgeendcoords(:,2).';
tp@0 94 edgeend(:,2) = reshape(A(onesvec1,:),ntot,1);
tp@0 95
tp@0 96 A = edgeendcoords(:,3).';
tp@0 97 edgeend(:,3) = reshape(A(onesvec1,:),ntot,1);
tp@0 98
tp@0 99 %------------------------------------------------------------
tp@0 100 % Spread the edge points along the edge, including the end
tp@0 101 % points, but nudge them in a bit.
tp@0 102
tp@0 103 displacement = 1e-1;
tp@0 104
tp@0 105 edgedividervec = [displacement 1:nedgesubs-2 nedgesubs-1-displacement].'/(nedgesubs-1);
tp@0 106 edgedividervec = reshape(edgedividervec(:,onesvec3),ntot,1);
tp@0 107
tp@0 108 edgepointcoords = edgestart + (edgeend - edgestart).*edgedividervec(:,onesvec2);
tp@0 109
tp@0 110 %------------------------------------------------------------
tp@0 111 % Extra output data
tp@0 112
tp@0 113 if nedgesubs < 8
tp@0 114 weightvec = uint8(2.^[0:nedgesubs-1].');
tp@0 115 elseif nedgesubs < 16
tp@0 116 weightvec = uint16(2.^[0:nedgesubs-1].');
tp@0 117 else
tp@0 118 weightvec = uint32(2.^[0:nedgesubs-1].');
tp@0 119 end
tp@0 120
tp@0 121 weightvec = reshape(weightvec(:,onesvec3),ntot,1);
tp@0 122
tp@0 123 if returnedgenumbers == 1
tp@0 124 if nedges < 256
tp@0 125 edgenumberlist = uint8([1:nedges]);
tp@0 126 elseif nedges < 65536
tp@0 127 edgenumberlist = uint16([1:nedges]);
tp@0 128 else
tp@0 129 edgenumberlist = uint32([1:nedges]);
tp@0 130 end
tp@0 131 edgenumberlist = reshape(edgenumberlist(onesvec1,:),ntot,1);
tp@0 132 else
tp@0 133 edgenumberlist = [];
tp@0 134 end