How to rotate object such that it's axis aligns with eigenvectors'?



Hi,

I'm trying to create an ellipsoid whose semi-axes are the
same as those of a set of eigenvectors. The length of the
semi-axes will be the eigenvalues. In the final application
there will be a large number of ellipsoids so it all has to
be automated. Each ellipsoid represents the diffusion
tensor at that location.

My idea was to create the ellipsoid, specifying the
semi-axes lengths as the eigenvalues and then rotate it so
it's axes align with the eigenvectors. At the moment I'm
just trying to align an axis (a group of 3 line objects)
with the eigenvectors to get it working. Using the
spherical coordinates of the eigenvectors, theta & phi, I
rotate the object around the y-axis by -xphi and then rotate
around the z-axis by xtheta. This aligns the two x-axes and
the other two axis are in the correct plane but in need of
rotation about the x-axis.

I can't figure out what angle to rotate around the x-axis to
get the other two axes aligned.

So, any ideas? Better solutions?

Cheers,
simon.


example code:

%%%eg:
v =[ -0.45599 0.52276 -0.72028;
0.66857 -0.33299 -0.66493;
-0.58744 -0.78476 -0.19766];
d =[
0.0004927
0.0001837
0.0014564];

figure
axey = axes('xlim',[-1 1],'ylim',[-1 1],'zlim',[-1 1]);
view(3); grid on; axis equal; hold on;
xlabel('x');ylabel('y');zlabel('z');

tx = line([0 v(1,1)],[0 v(2,1)],[0 v(3,1)],'Color','b');
ty = line([0 v(1,2)],[0 v(2,2)],[0 v(3,2)],'Color','r');
tz = line([0 v(1,3)],[0 v(2,3)],[0 v(3,3)],'Color','g');
az = line([0 0],[0 0],[0 1],'Color','g','Linestyle',':');
ay = line([0 0],[0 1],[0 0],'Color','r','Linestyle',':');
ax = line([0 1],[0 0],[0 0],'Color','b','Linestyle',':');

hg = hggroup;
set(ax,'Parent',hg);
set(ay,'Parent',hg);
set(az,'Parent',hg);

t = hgtransform;
set(hg,'Parent',t);

[xtheta,xphi,un] = cart2sph(v(1,1),v(2,1),v(3,1));
[ytheta,yphi,un] = cart2sph(v(1,2),v(2,2),v(3,2));
[ztheta,zphi,un] = cart2sph(v(1,3),v(2,3),v(3,3));

%%%aligns x axes
rz = makehgtform('zrotate',xtheta); %x
ry = makehgtform('yrotate',-xphi); %x
set(t,'matrix',rz*ry);

%%%aligns y-axes
%ry1 = makehgtform('xrotate',yphi); %y -> rz*ry
%rx1 = makehgtform('yrotate',yphi); %neg = clckwse
%set(t,'matrix',rz1*ry1);
.



Relevant Pages

  • Re: extracting angle info from ellipsoid equation
    ... rotated ellipsoid equation of the form: ... By "rotation angle" I presume you are asking for the directions of this ... Form the symmetric matrix M and find its eigenvalues and eigenvectors: ... principal axes with respect to the original coordinate system. ...
    (comp.soft-sys.matlab)
  • Re: ellipsoid axis length
    ... we know that the principle ... axes of the ellipsoid is given by the eigenvectors of A. Now how do we ...
    (sci.math)
  • ellipsoid axis length
    ... we know that the principle ... axes of the ellipsoid is given by the eigenvectors of A. Now how do we ...
    (sci.math)

Loading