Home > marsbar > @maroi_box > voxpts.m

voxpts

PURPOSE ^

voxpts method - voxels within a box in given space

SYNOPSIS ^

function [pts, vals] = voxpts(obj, sp)

DESCRIPTION ^

 voxpts method - voxels within a box in given space

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [pts, vals] = voxpts(obj, sp)
0002 % voxpts method - voxels within a box in given space
0003 %
0004 % $Id$
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 % find voxels that are within box
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));

Generated on Wed 11-May-2022 15:34:44 by m2html © 2003-2019