1 | function [box zero range eigvec]=make_box3(points,num_of_points)
|
---|
2 |
|
---|
3 | %OK
|
---|
4 |
|
---|
5 | N=size(points,1);
|
---|
6 | dim=size(points,2);
|
---|
7 |
|
---|
8 | meanval=mean(points,1);
|
---|
9 | medianval=2*(median(abs(points-ones(N,1)*meanval),1));
|
---|
10 | eigvec=eye(3);
|
---|
11 |
|
---|
12 | %range=1.5*sqrt(diag(eigval)/N);
|
---|
13 | %pom=points*eigvec/2;
|
---|
14 | %range=min((max(pom)-min(pom))',range);
|
---|
15 | %range=(max(points)-min(points))';
|
---|
16 | range=medianval';
|
---|
17 |
|
---|
18 |
|
---|
19 | box=zeros(N,dim);
|
---|
20 | pointer=-range;
|
---|
21 | pointer(3)=(min(points))*[0;0;1];
|
---|
22 | step=2*range/(num_of_points-1);
|
---|
23 | jump=[1 num_of_points num_of_points^2];
|
---|
24 | for i=1:N
|
---|
25 | for k=1:dim
|
---|
26 | box(i,k)=pointer(k)+step(k)*mod(floor((i-1)/jump(k)),num_of_points);
|
---|
27 | end
|
---|
28 | end
|
---|
29 |
|
---|
30 | box=box+ones(N,1)*(meanval.*[1 1 0]);
|
---|
31 | range=ones(3,1)./(2*range);
|
---|
32 | zero=box(1,:);
|
---|
33 |
|
---|
34 | plot3(points(:,1),points(:,2),points(:,3),'r.');
|
---|
35 | hold on;
|
---|
36 | plot3(box(:,1),box(:,2),box(:,3),'g.');
|
---|
37 | hold off;
|
---|
38 |
|
---|
39 | %plot3(box(1,1),box(1,2),box(1,3),'r+');
|
---|
40 | %plot3(box(2,1),box(2,2),box(2,3),'b+');
|
---|
41 | %plot3(box(3,1),box(3,2),box(3,3),'b+');
|
---|
42 |
|
---|
43 | %plot3(box(64,1),box(64,2),box(64,3),'g+');
|
---|
44 | %plot3(box(4,1),box(4,2),box(4,3),'b+');
|
---|
45 | end |
---|