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