Add from_speed_yaw to vector helpers
parent
638028dea3
commit
68545f6672
|
@ -143,4 +143,13 @@ function vector.get_yaw(pos1, pos2)
|
|||
return math.atan2(dx, dz)
|
||||
end
|
||||
|
||||
function vector.from_speed_yaw(speed, yaw)
|
||||
if speed == 0 then
|
||||
return {x=0, y=0, z=0}
|
||||
end
|
||||
yaw = yaw + math.pi / 2
|
||||
local x = math.cos(yaw) * speed
|
||||
local z = math.sin(yaw) * speed
|
||||
return {x=x, y=0, z=z}
|
||||
end
|
||||
|
||||
|
|
|
@ -1585,6 +1585,9 @@ Vector helpers
|
|||
* 'vector.interpolate(p1, p2, factor)': returns a vector
|
||||
* `vector.get_yaw(p1, p2)`: returns a number
|
||||
*Gets the yaw angle to point at p2 from p1
|
||||
* `vector.from_speed_yaw(speed, yaw)`
|
||||
* Gets a vector representing the given speed and yaw direction.
|
||||
(y component will always be 0)
|
||||
|
||||
For the following functions `x` can be either a vector or a number:
|
||||
|
||||
|
|
Loading…
Reference in New Issue