Rotation axis

Submitted by JoshuaP on Wed, 12/17/2014 - 14:55

Hey,

I'm trying to rotate and translate a mesh. But I want the mesh to move in z-direction in the rotated system and not in the inertia system. So I'm doing 3 rotations with

mesh_->rotate(totalPhix_,incrementalPhix,axisx_,reference_point);
vectorScalarMult3D(axisx_,omegax_,omegaVecx);
mesh_->rotate(totalPhiy_,incrementalPhiy,axisy_,reference_point);
vectorScalarMult3D(axisy_,omegay_,omegaVecy);
mesh_->rotate(totalPhiz_,incrementalPhiz,axisz_,reference_point);
vectorScalarMult3D(axisz_,omegaz_,omegaVecz);

and a linear movement in the rotated system in z with

vectorScalarMult3D(axisz_,vz,vel_[2]); // <-create a vector in z axis with length vz
// calculate total and incremental displacement
vectorScalarMult3D(vel_,dt,dx);
vectorAdd3D(dX_,dx,dX_);
// apply move
mesh_->move(dX_,dx);

The problem now is that the axisz_ vector is not rotated with the mesh. Therefor, I try to rotate the vector each step with

RotMatrix(incrementalPhix, incrementalPhiy, incrementalPhiz, Dnew_);
MatrixMultisMatrix(Dold_,Dnew_,Dold_); //matrix multiplication
MatrixMultisVector(Dold_, eyex_,axisx_); //matrix vector multiplication
MatrixMultisVector(Dold_, eyey_,axisy_);
MatrixMultisVector(Dold_, eyez_,axisz_);

where eye* is the unit vector in each direction. The RotMatrix is build up like in this paper for "kardan-winkel" (page 1 Matrix S)
http://www.itm.uni-stuttgart.de/courses/madyn/Merkblaetter/M08.pdf

the rotMatrix for 3 rotations is calculated on this way
D*D'*D''*eyez_
where D is the first rotation and D'' is the last.
But somehow the calculation of the rotated axis is wrong. Is there a function which I could use to rotate the axis with the mesh??

Thanks
Joshua

ckloss's picture

ckloss | Wed, 01/14/2015 - 18:43

Hi Joshua,

where (which file) are you writing this code? There is quite many places in the code which play together to perform mesh movement, and if one part is missing some things are messed up.
Which outcome do you want to achieve?

Best wishes
Christoph

JoshuaP | Thu, 01/15/2015 - 10:11

Hi Christoph,

I'm in the mesh_mover.cpp and after I did 3 rotation in an incremental step I want to move linear forward in the new z axis. Also all rotation should be around the new rotated system each step. So for the linear movement after rotation I want to multiply the axisz_ vector with a velocity to get the new velocity vector.

Thanks
Joshua

ckloss's picture

ckloss | Mon, 01/19/2015 - 10:00

>> Is there a function which I could use to rotate the axis with the mesh??
Hi Joshua,

yes this is possible, but involves some coding. Look at fix mesh surface stress, it uses the "addGlobalProperty" function to add a point/vector which is rotated in the local coordinate system

Cheers
Christoph

JoshuaP | Tue, 01/20/2015 - 11:09

Thanks Christoph,
I think I solved it.
I have one more question...
is the torque of a rotated mesh calculated around the original axis or around a rotated axis? And if I move the mesh, is the reference point from the fix mesh/surface/stress command automatically moved with the mesh?
Thanks
Joshua