How SFRotation Works in 3D World Editor?

4 次查看(过去 30 天)
I am trying to hook up my UAV Simulink model to VR Sink by sending translation and rotation values from my model to VR Sink. I am able to successfully input translation values but I am confused on how I can send my model's Euler angles. I have the following rotation angles that I am trying to send to VR Sink: roll (reference frame is x-axis counter-clockwise), pitch (reference frame is y-axis counter-clockwise), and yaw (reference frame is z-axis counter-clockwise). How do I convert these Euler angles with their respective reference frames to a 4 element vector that is required in VR Sink?

回答(1 个)

Muhammet Dabak
Muhammet Dabak 2020-10-14
编辑:Muhammet Dabak 2021-9-29
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 = rYaw*rPitch*rRoll;
vector=vrrotmat2vec(Rotation);
end
Roll,yaw,pitch angles' order can change due to your coordinate system, you can arrange it.
For any question, I will be glad to answer related to V-Realm Builder & 3D World Editor

Community Treasure Hunt

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

Start Hunting!

Translated by