如何找到本征主方向? [英] How to find principal eigen direction?

查看:167
本文介绍了如何找到本征主方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在椭球内生成点,然后尝试与光滑的椭球表面拟合.目标是适应未知数据,其中我必须在3个主轴上找到a,b和c的值. Rinv应该等同于pc.但是我以不同的顺序得到电脑.所以我必须找到正确的顺序来将我的数据旋转到matlab坐标.

I am trying to generate points within ellipsoid and then trying to fit with smooth ellipsoid surfaces. The goal is to fit with unknown data where i have to find value of a,b and c in 3 principal axes. Rinv should be equivalent to pc. But what i am getting pc in different order. So i have to find correct order to rotate my data to matlab coordinate.

a=3;
b=5;
c=1;
index=1;
for i=1:500000
    x=10*rand-5;
    y=10*rand-5;
    z=10*rand-5;
    if ((x^2/a^2) + (y^2/b^2) + (z^2/c^2) -1) <0
        C(index,:)=[x,y,z];
        index=index+1;
    end
end

theta=pi/4; phi=pi/6; omega = pi/3;
Rx= [1 0 0; 0 cos(theta) -sin(theta); 0 sin(theta) cos(theta)];
Ry= [cos(phi) 0 sin(phi); 0 1 0; -sin(phi) 0 cos(phi)];
Rz= [cos(omega) -sin(omega) 0; sin(omega) cos(omega) 0; 0 0 1];
R= Rz*Ry*Rx; 
Rinv = inv(R);
X = C*R;
[pc,val]=eig(X'*X); E=diag(val);
[sa,sb]= sort(pc*E, 'descend');   sb 
order = [2,3,1];
nC= X*pc(:,order);
plot3(nC(:,1),nC(:,2),nC(:,3),'.')
hold on 
[x, y, z] = ellipsoid(0,0,0,a,b,c,30);
hSurface=surf(x, y, z, 'FaceColor','blue','EdgeColor','none');
alpha(0.5) 

特别是在这行中nC = X * pc(:,order); 我正在手动查找订单.谁能告诉(1)如何正确找到PC订单. (2)此处未知数据集的a,b,c值"[x,y,z] =椭球(0,0,0,a,b,c,30)" 谢谢

Specially in this line nC= X*pc(:,order); I am finding order manually. Can any one tells (1) how to find pc order correctly. (2) Value of a,b,c for unknown data set here "[x, y, z] = ellipsoid(0,0,0,a,b,c,30)" Thanks

推荐答案

要从本征空间计算a,b,c的值,您只需要计算本征空间投影椭球的半径即可.这是微不足道的,因为椭圆体在本征空间中是面向轴的(我认为这是您首先这样做的唯一原因).只需获取每个方向上的最大值和最小值即可!

To compute the values of a,b,c from the eigen-space, you just need to compute the radius of the eigen-space projected ellipsoid. This is trivial because the ellipsoid is axis-oriented in eigen-space (which I assume is the only reason you are doing this in the first place). Just get the max and min in each direction!

nC= X*pc;
plot3(nC(:,1),nC(:,2),nC(:,3),'r.')
hold on 

a2=(max(nC(:,1))-min(nC(:,1)))/2;
b2=(max(nC(:,2))-min(nC(:,2)))/2;
c2=(max(nC(:,3))-min(nC(:,3)))/2;

[x, y, z] = ellipsoid(0,0,0,a2,b2,c2,30);
hSurface=surf(x, y, z, 'FaceColor','blue','EdgeColor','none');
alpha(0.5) 
axis equal

请注意,此代码实际上使order过时.

Note that this code actually makes order obsolete.

这篇关于如何找到本征主方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆