# How does SFRotation works in Simulink 3D world Editor?

48 views (last 30 days)
Pranjal Biswas on 11 Jan 2017
Answered: Muhammet Dabak on 14 Oct 2020
I am new to Simulink 3D Animation. I have been trying to use the Simulink 3D World Editor. My aim is to translate and rotate a helicopter model. I was able to create the 3D world along with the helicopter. My model is accurate when it comes to translation, but I am not able to understand how rotation works. I have checked the sfrotation block in block parameters. But when I input 3by1 matrix to rotation input of vrsink block in Simulink, it says dimensions are not correlating and asks for 4th dimension. Can someone please explain how can I get accurate rotation of my model in all 3 axis(roll, pitch, yaw)?

Vishal Neelagiri on 17 Jan 2017
'SFRotation' represents a vector of four floating point values you use for specifying rotation coordinates (x,y,z) of an axis plus rotation angle around that axis. You can find this description in the following documentation page:
https://www.mathworks.com/help/sl3d/vrml-data-types.html
You can also read through the following documentation for information to link to simscape multibody models in order to obtain the positions and rotations of machine parts using Body sensor blocks.

Muhammet Dabak on 14 Oct 2020
function vector=Rotator(yaw,pitch,roll)
rRoll=[cosd(roll),-sind(roll),0;sind(roll),cosd(roll),0;0,0,1];
rYaw=[cosd(yaw), 0, sind(yaw); 0,1,0; -sind(yaw) ,0, cosd(yaw)]
rPitch=[1, 0, 0; cosd(pitch), -sind(pitch), 0 ;0 ,sind(pitch) ,cosd(pitch)]
Rotation = rRoll*rYaw*rPitch;
vector=vrrotmat2vec(Rotation);
end
This yaw,pitch,roll can change with respect to your coordinate system.
For any question, I can answer it.