Rotation of a patch using eigenvectors

9 visualizzazioni (ultimi 30 giorni)
Cristiana Abilheira
Cristiana Abilheira il 11 Mar 2019
Risposto: darova il 11 Mar 2019
I've got an STL imported file, this file is randomly positioned in space. I want to regulate its position in order to get its symmetry axis overlapping with the coordinated axis. I used the Inertia tensor and eigen vectors and eigenvalues. However, I thought that would be enough to multiply the x,y,z coordinate matrix of my data by the eigenvector matrix to get it. I am wrong for sure because it's not what I am geting. What is missing? Help please
The code below
%First I have a Function to find geometric center of surface, then translation of surface in order to overlap geometric center and axis origin
%Function to calculate Inertia Tensor
function [ I ] = InertiaTensor( TrianglesGeometricCenter,AreaMatrix )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
A=AreaMatrix
GCtri=TrianglesGeometricCenter
for i=1:length(GCtri)
Ixx=sum(A(i)*(GCtri(i,2)^2+GCtri(i,3)^2))
Iyy=sum(A(i)*(GCtri(i,1)^2+GCtri(i,3)^2))
Izz=sum(A(i)*(GCtri(i,1)^2+GCtri(i,2)^2))
Ixy=sum(A(i)*(GCtri(i,1)*GCtri(i,2)))
Iyx=sum(A(i)*(GCtri(i,1)*GCtri(i,2)))
Ixz=sum(A(i)*(GCtri(i,1)*GCtri(i,3)))
Izx=sum(A(i)*(GCtri(i,1)*GCtri(i,3)))
Iyz=sum(A(i)*(GCtri(i,2)*GCtri(i,3)))
Izy=sum(A(i)*(GCtri(i,2)*GCtri(i,3)))
end
I=[Ixx Ixy Ixz;Iyx Iyy Iyz; Izx Izy Izz]
assignin('base','I',I)
end
%Get eigenvectores and eigenvalues
[Q,W]=eig(I)
%V is data matrix
R=V*Q
%Surface plot and I can see some rotation but not to the expected place

Risposte (1)

darova
darova il 11 Mar 2019
If you have center of your body and you can manually get axis symmetry - use rotation matrix
Here vector is normal vector of plane created of three point (O c0 p0)
f259f80a746ee20d481f9b7f600031084358a27c
Then just simply multiple each point by R
latex.gif
gg.png

Community Treasure Hunt

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

Start Hunting!

Translated by