function getSmoothRotation(P)local F=P[1]local t=P[2]local s=tankStats.GunHandling.GunDepression.Value local U=tankStats.GunHandling.GunTraverse.Value if math.abs(F)>s then F=s*sign(F)end if math.abs(t)>U then t=U*sign(t)end local Y=F-currentElev if math.abs(Y)<.01 then currentElev=F else currentElev=currentElev+.01*sign(Y)end local R=t-currentRot local C=tankStats.GunHandling.TurretSpeed.Value if math.abs(R)<C then currentRot=t else currentRot=currentRot+C*sign(R)end local e={}e[1]=F e[2]=t return e end

function getSmoothRotation(rotations)
	
	local targElev = rotations[1];
	local targRot = rotations[2];	
	
	local maxGunDepression = tankStats.GunHandling.GunDepression.Value;	
	local maxTraverse = tankStats.GunHandling.GunTraverse.Value;	

	-- Restrict the height of travel of the gun
	if math.abs(targElev) > maxGunDepression then
		targElev = maxGunDepression*sign(targElev);
	end
	
	if math.abs(targRot) > maxTraverse then
		targRot = maxTraverse*sign(targRot);
	end
	

	-- Once target angles are set, slowly turn turret towards them
	-- Elevation
	local elevDiff = targElev - currentElev;
	if math.abs(elevDiff) < 0.01 then -- If they're close
		currentElev = targElev;
	else -- Move towards it
		currentElev = currentElev + 0.01*sign(elevDiff);
	end



	local rotDiff = targRot - currentRot;
	local turretSpeed = tankStats.GunHandling.TurretSpeed.Value;
	
	if math.abs(rotDiff) < turretSpeed then -- If they're close
		currentRot = targRot;
	else -- Move towards it
		currentRot = currentRot + turretSpeed*sign(rotDiff);
	end
	
	-- Put rotation and elevation into an array
	local rotations = {};
	rotations[1] = targElev;
	rotations[2] = targRot;
	
	return rotations;
end
