Guest User

steerByRaw.ks

a guest
Apr 7th, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. DECLARE PARAMETER steerVector.
  2.  
  3. set directionVector to VXCL(ship:facing:foreVector, steerVector).
  4. if VANG(ship:facing:starVector, directionVector) > 90 {
  5. set vectorAngle to VANG(ship:facing:topVector,directionVector).
  6. }
  7. else { set vectorAngle to 360-VANG(ship:facing:topVector,directionVector). }.
  8. set facingAngle to VANG(ship:facing:foreVector, steerVector).
  9. set pitchAngle to cos(vectorAngle)*facingAngle.
  10. set yawAngle to sin(vectorAngle)*facingAngle.
  11.  
  12. set pitchE0 to pitchAngle.
  13. set yawE0 to yawAngle.
  14. set rollE0 to ship:facing:roll.
  15. set t0 to time:seconds.
  16.  
  17. WAIT 0.05.
  18.  
  19. set directionVector to VXCL(ship:facing:foreVector, steerVector).
  20. if VANG(ship:facing:starVector, directionVector) > 90 {
  21. set vectorAngle to VANG(ship:facing:topVector,directionVector).
  22. }
  23. else { set vectorAngle to 360-VANG(ship:facing:topVector,directionVector). }.
  24. set facingAngle to VANG(ship:facing:foreVector, steerVector).
  25. set pitchAngle to cos(vectorAngle)*facingAngle.
  26. set yawAngle to sin(vectorAngle)*facingAngle.
  27.  
  28. set t1 to time:seconds.
  29. set pitchE1 to pitchAngle.
  30. set yawE1 to yawAngle.
  31. set rollE1 to ship:facing:roll.
  32.  
  33. set dPitch to (pitchE1 - pitchE0)/(t1 - t0).
  34. set dYaw to (yawE1 - yawE0)/(t1 - t0).
  35. set dRoll to (rollE1 - rollE0)/(t1 - t0).
  36.  
  37. set ship:control:pitch to (pitchP*pitchE1 + pitchD*dPitch).
  38. set ship:control:yaw to -1*(yawP*yawE1 + yawD*dYaw).
  39. set ship:control:roll to (rollD*dRoll).
Advertisement
Add Comment
Please, Sign In to add comment