Advertisement
Faguss

Optimised Rotate3d

Oct 18th, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. private ["_vehicle", "_dir", "_pos", "_yaw", "_bank", "_pitch", "_side", "_y", "_z", "_xy", "_xz", "_yz", "_yx", "_zx", "_zy"];
  2.  
  3.  
  4. _vehicle = _this select 0;
  5. _dir = getDir2 _vehicle;
  6. _pos = getPosASL _vehicle;
  7.  
  8. //_yaw = getdir _vehicle;
  9. //_yaw = -_yaw;
  10. //_bank1 = (vehicle player) call GetBank;
  11. //_pitch1 = (vehicle player) call GetPitch;
  12.  
  13. _yaw = -(_dir select 0);
  14. _bank = _dir select 1;
  15. _pitch = _dir select 2;
  16.  
  17. //player globalchat format ["%1 %2 %3 %4", _pitch1, _pitch, abs (_pitch1 - _pitch),DUPA];
  18. //if (abs (_pitch1 - _pitch) > DUPA && abs (_pitch1 - _pitch) < 900 ) then {DUPA=abs (_pitch1 - _pitch)};
  19.  
  20. //player globalchat format ["%1 %2 %3", _bank1, _bank, abs (_bank1 - _bank)];
  21. //if (abs (_bank1 - _bank) > DUPA && abs (_bank1 - _bank) < 900 ) then {DUPA=abs (_bank1 - _bank)};
  22.  
  23.  
  24. _side = _this select 1;
  25. _forward = _this select 2;
  26. _up = _this select 3;
  27.  
  28.  
  29.  
  30. // Rotation around the bank
  31. _Z = cos(_bank)*_up - sin(_bank)*_side;
  32.  
  33. // Rotation around the pitch
  34. _xy = cos(_pitch)*_forward - sin(_pitch)*_Z;
  35. _Z = sin(_pitch)*_forward + cos(_pitch)*_Z;
  36.  
  37. // Rotation around the bank
  38. _X = sin(_bank)*_up + cos(_bank)*_side;
  39.  
  40. // Rotation around the yaw
  41. _Y = sin(_yaw)*_X + cos(_yaw)*_xy;
  42. _X = cos(_yaw)*_X - sin(_yaw)*_xy;
  43.  
  44. [
  45. (_pos select 0) + _X,
  46. (_pos select 1) + _Y,
  47. (_pos select 2) + _Z
  48. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement