0

So I'm trying to get the vector given the yaw, pitch, and roll using this formula

var x = (-Math.cos(yaw) * Math.sin(pitch) * Math.sin(roll)) - (Math.sin(yaw) * Math.cos(roll));
var y = (-Math.sin(yaw) * Math.sin(pitch) * Math.sin(roll)) + (Math.cos(yaw) * Math.cos(roll));
var z = (Math.cos(pitch) * Math.sin(roll));

I tried to plot it in a 3d space and the left and right direction seems correct but the direction up and down is different. The direction up is current at position (0,-1,0) as (X,Y,Z).

How do I rotate it so that the direction up is at (0,0,-1) as (X,Y,Z)?

  • This is more a math question, not a programming question. –  Apr 14 '20 at 07:33
  • Hmmm you're right apologies, I should have added math as a tag – Bryll Delfin Apr 14 '20 at 08:05
  • I meant more like posting on https://math.stackexchange.com/ instead :) –  Apr 14 '20 at 09:12
  • Also, when I tried my hand at a wing commander type game I calculated a perpendicular rotation axis (perpendicular to the flight direction) based on yaw and pitch, created a quaternion from that and rotated around that. As far as I can tell the key is to create the rotation matrix in the craft's system, convert it to the world system, then apply it to the craft. –  Apr 14 '20 at 09:15

0 Answers0