function getSmoothRotation(a)local z=a[1]local U=a[2]local c=tankStats.GunDepression.Value if math.abs(z)>c then z=c*sign(z)end local Q=z-currentElev if math.abs(Q)<.01 then currentElev=z else currentElev=currentElev+.01*sign(Q)end local O=U-currentRot if O>math.pi then O=O-2*math.pi elseif O<-math.pi then O=O+2*math.pi end local R=tankStats.TurretSpeed.Value if math.abs(O)<R then currentRot=U else currentRot=currentRot+R*sign(O)end local C={}C[1]=z C[2]=U return C end

function getSmoothRotation(rotations)
	
	local targElev = rotations[1];
	local targRot = rotations[2];	
	
	local maxGunDepression = tankStats.GunDepression.Value;
	
	-- Restrict the height of travel of the gun
	if math.abs(targElev) > maxGunDepression then
		targElev = maxGunDepression*sign(targElev);
	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
	
	-- Rotation
	local rotDiff = targRot - currentRot;
	
	if rotDiff > math.pi then
		rotDiff = rotDiff - 2*math.pi;
	elseif rotDiff < -math.pi then
		rotDiff = rotDiff + 2*math.pi;
	end
	
	local turretSpeed = tankStats.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
