Deriving rotation angle from the eigenvectors

조회 수: 18 (최근 30일)
Sophie Wuerger
Sophie Wuerger 2019년 10월 15일
편집: Matt J 2022년 3월 15일
For an ellipsoid, how can I get the rotation angle from the eigenvectors?
  댓글 수: 3
Sophie Wuerger
Sophie Wuerger 2019년 10월 15일
편집: Matt J 2022년 3월 15일
I think I just found the solution for the 3d rotation.
[center,radii,ecvecs,v,chi2]=ellipsoid_fit(dat,'');
[x, y, z] = ellipsoid(center(1), center(2),center(3), radii(1),radii(2),radii(3),30);
S=surf(x, y, z,'FaceAlpha', 0.3, 'EdgeColor', 'none', 'FaceLighting', 'gouraud')
.....
theta1 = -asind(R(3,1)); % y-axis
psi1 = atan2d(R(3,2)/cos(theta1),R(3,3)/cos(theta1)); % x-axis
phi1 = atan2d(R(2,1)/cos(theta1),R(1,1)/cos(theta1)); % z-axis
direction = [1 0 0]; %
rotate(S,direction,psi1,center)
direction = [0 1 0];
rotate(S,direction,theta1,center)
direction = [0 0 1];
rotate(S,direction,phi1,center)
Does that look allright?
Is there an easy way to obtain the projection onto the axes?
best
sophie
Qingda Hu
Qingda Hu 2022년 3월 15일
Probably too late but I was trying to use the same ellipsoid_fit function
If you linearize x,y,z and just multiple it by the evecs you get what you want
[center, radii, evecs, pars ] = ellipsoid_fit_new(... );
[X,Y,Z] = ellipsoid(0,0,0,radii(1),radii(2),radii(3));
Xlin = X(:);
Ylin = Y(:);
Zlin = Z(:);
rotatedXYZ = [Xlin,Ylin,Zlin]*evecs';
X = reshape( rotatedXYZ(:,1),size(X));
Y = reshape( rotatedXYZ(:,2),size(X));
Z = reshape( rotatedXYZ(:,3),size(X));
surf(X,Y,Z);
(you can translate it as well)
Hopefully this is useful for someone.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2022년 3월 15일
편집: Matt J 2022년 3월 15일
If you download ellipsoidalFit() to do the fitting, the yaw-pitch-roll angles are avaialble directly from the object,
>> load data
>> fitobj=ellipsoidalFit(xyz)
fitobj =
ellipsoidalFit with properties:
center: [5.0483 2.0378 7.0195]
a: 20.0700
b: 10.0469
c: 4.9622
yaw: 39.6951
pitch: -29.7995
roll: 50.4333

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by