function getCameraHeadingAngle(x, y)
local cx, cy, _ = getActiveCameraCoordinates()
return math.rad(getHeadingFromVector2d(x - cx, y - cy) - 90)
end
function smoothCameraRotation(time_s, angle)
lua_thread.create(function()
start_time = os.clock()
local x, y, _ = getActiveCameraPointAt()
local d_Z = getCameraHeadingAngle(x, y)
local d_ang = angle - d_Z
if d_ang >= -2 * math.pi and d_ang <= -1 * math.pi then
d_ang = d_ang + 2 * math.pi
elseif d_ang >= math.pi and d_ang <= 2 * math.pi then
d_ang = d_ang - 2 * math.pi
end
local c_time = start_time
while c_time <= start_time + time_s do
local c_angle = d_Z + d_ang * (c_time - start_time) / time_s
setCameraPositionUnfixed(0, c_angle)
wait(0)
c_time = os.clock()
end
setCameraPositionUnfixed(0, angle)
end)
end