Re: Untitled

By Commodious Peccary, 5 Years ago (2014-10-20 22:10:51), written in Lua, viewed 394 times. This paste is a reply to Untitled by Tiny Cat
URL https://paste.godclan.hu/view/1v6GqPwU Embed
Download Paste or View RawExpand paste to full width of browser
  1. function baseRotate(x, y, rz)
  2.     local x2 = x * cos(rz) - y * sin(rz)
  3.     local y2 = x * sin(rz) + y * cos(rz)
  4.     return x2, y2
  5. end
  6.  
  7. -- ZYX rotation
  8. function rotate(x, y, z, rx, ry, rz)
  9.     y, z = baseRotate(y, z, rx)
  10.     x, z = baseRotate(-x, z, ry)
  11.     x = -x
  12.     x, y = baseRotate(x, y, rz)
  13.     return x, y, z
  14. end
  15.  
  16. function setTurnVelocityAlong(vehElement, x, y, z, v)
  17.     -- Normalize vector
  18.     local r = sqrt(x * x + y * y + z * z)
  19.     local x2 = x / r
  20.     local y2 = y / r
  21.     local z2 = z / r
  22.  
  23.     -- Rotate vector
  24.     local rx, ry, rz = getElementRotation(vehElement, "ZYX")
  25.     x, y, z = rotate(x2, y2, z2, rx, ry, rz)
  26.  
  27.     -- Set turn velocity
  28.     x, y, z = x * v, y * v, z * v
  29.     return setVehicleTurnVelocity(vehElement, x, y, z)
  30. end

Replies to Re: Untitled rss

Title Name When
Re: Re: Untitled Paltry Bushbaby 5 Years ago.
Re: Re: Untitled Bitty Lemur 5 Years ago.

Reply to "Re: Untitled"

Here you can reply to the paste above