-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgridSpac.m
52 lines (36 loc) · 1.11 KB
/
gridSpac.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function [lMin, lMax, minL, maxL] = gridSpac(xb,yb,zb)
[ni,~,~]=size(xb);
Z=squeeze(zb(1:ni/2,:,:));
Y=squeeze(yb(1:ni/2,:,:));
X=squeeze(xb(1:ni/2,:,:));
xyz=cat(4,X,Y,Z);
xyz_corner=xyz([1 end],[1 end],[1 end],:);
dI=xyz(2:end,:,:,:)-xyz(1:end-1,:,:,:);
lI=vecnorm(dI,2,4);
lMinI=min(lI(:));
lMaxI=max(lI(:));
dI=xyz_corner(2,:,:,:)-xyz_corner(1,:,:,:);
lI=vecnorm(dI,2,4);
edgeMinI=min(lI(:));
edgeMaxI=max(lI(:));
dJ=xyz(:,2:end,:,:)-xyz(:,1:end-1,:,:);
lJ=vecnorm(dJ,2,4);
lMinJ=min(lJ(:));
lMaxJ=max(lJ(:));
dJ=xyz_corner(:,2,:,:)-xyz_corner(:,1,:,:);
lJ=vecnorm(dJ,2,4);
edgeMinJ=min(lJ(:));
edgeMaxJ=max(lJ(:));
dK=xyz(:,:,2:end,:)-xyz(:,:,1:end-1,:);
lK=vecnorm(dK,2,4);
lMinK=min(lK(:));
lMaxK=max(lK(:));
dK=xyz_corner(:,:,2,:)-xyz_corner(:,:,1,:);
lK=vecnorm(dK,2,4);
edgeMinK=min(lK(:));
edgeMaxK=max(lK(:));
lMin=min([lMinI,lMinJ,lMinK]);
lMax=max([lMaxI,lMaxJ,lMaxK]);
minL = min([edgeMinI,edgeMinJ,edgeMinK]);
maxL=max([edgeMaxI,edgeMaxJ,edgeMaxK]);
return