0001 function [pts, vals] = voxpts(obj, sp)
0002
0003
0004
0005
0006 if nargin < 2
0007 error('Need object and space arguments');
0008 end
0009 sp = mars_space(sp);
0010
0011 mc = obj.centre;
0012 mw = obj.widths;
0013
0014
0015 dim = sp.dim(1:3); dim = dim(:);
0016 vox = sqrt(sum(sp.mat(1:3,1:3)'.^2));
0017 vd = mw ./ vox / 2;
0018 vc = sp.mat \ [mc(1:3) 1]';
0019 vc = vc(1:3)';
0020 blim = [max([1 1 1; ceil(vc-vd)]); min([sp.dim(1:3); floor(vc+vd)])];
0021 [R,C,P]=ndgrid(...
0022 blim(1,1):blim(2,1),blim(1,2):blim(2,2),blim(1,3):blim(2,3));
0023 pts = [R(:)';C(:)';P(:)'];
0024
0025 vals = ones(1, size(pts, 2));