Advertisement
Faguss

Correct Rotate 3d

Oct 18th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 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. // Rotation around the bank
  30. _xy = cos(0)*_forward - sin(0)*_up;
  31. _xz = sin(0)*_forward + cos(0)*_up;
  32.  
  33. _yz = cos(_bank)*_xz - sin(_bank)*_side;
  34. _yx = sin(_bank)*_xz + cos(_bank)*_side;
  35.  
  36. _zx = cos(0)*_yx - sin(0)*_xy;
  37. _zy = sin(0)*_yx + cos(0)*_xy;
  38.  
  39.  
  40. // Rotation around the pitch
  41. _xy = cos(_pitch)*_zy - sin(_pitch)*_yz;
  42. _xz = sin(_pitch)*_zy + cos(_pitch)*_yz;
  43.  
  44. _yz = cos(0)*_xz - sin(0)*_zx;
  45. _yx = sin(0)*_xz + cos(0)*_zx;
  46.  
  47. _zx = cos(0)*_yx - sin(0)*_xy;
  48. _zy = sin(0)*_yx + cos(0)*_xy;
  49.  
  50.  
  51. // Rotation around the yaw
  52. _xy = cos(0)*_zy - sin(0)*_yz;
  53. _xz = sin(0)*_zy + cos(0)*_yz;
  54.  
  55. _yz = cos(0)*_xz - sin(0)*_zx;
  56. _yx = sin(0)*_xz + cos(0)*_zx;
  57.  
  58. _zx = cos(_yaw)*_yx - sin(_yaw)*_xy;
  59. _zy = sin(_yaw)*_yx + cos(_yaw)*_xy;
  60.  
  61. [
  62. (_pos select 0) + _zx,
  63. (_pos select 1) + _zy,
  64. (_pos select 2) + _yz
  65. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement