function [xpos2, ypos2] = partical_B_new_swapUV(xpos1, ypos1, u0, v0, lon1, lat1, ix, iy, dtuv, mask)
% 為 Arakawa-B grid 設計，並交換 u0 和 v0 的方向意義使用 %

xdif = (xpos1 - lon1(ix)) / (lon1(ix+1) - lon1(ix));
ydif = (ypos1 - lat1(iy)) / (lat1(iy+1) - lat1(iy));

if ix == 1 | ix == size(u0,1) | iy == 1 |iy == size(u0,2)
    xpos2 = xpos1;
    ypos2 = ypos1;
elseif mask(ix, iy) == 0
    xpos2 = xpos1;
    ypos2 = ypos1;
    return
else
    % 原本 u0 是東向（x），現在當作北向（y）
    % 原本 v0 是北向（y），現在當作東向（x）

    % Interpolate v0 --> 作為 x 方向速度
    v1 = v0(ix,iy);   v2 = v0(ix+1,iy);
    v3 = v0(ix+1,iy+1); v4 = v0(ix,iy+1);
    A = [v1, v2, v3, v4];
    AA = find(~isnan(A));
    if ~isempty(AA)
        for k = 1:4
            if isnan(A(k))
                A(k) = A(AA(1));
            end
        end
    end
    v1 = A(1); v2 = A(2); v3 = A(3); v4 = A(4);
    vx = (1 - xdif)*(1 - ydif)*v1 + xdif*(1 - ydif)*v2 + xdif*ydif*v3 + (1 - xdif)*ydif*v4;

    % Interpolate u0 --> 作為 y 方向速度
    u1 = u0(ix,iy);   u2 = u0(ix+1,iy);
    u3 = u0(ix+1,iy+1); u4 = u0(ix,iy+1);
    A = [u1, u2, u3, u4];
    AA = find(~isnan(A));
    if ~isempty(AA)
        for k = 1:4
            if isnan(A(k))
                A(k) = A(AA(1));
            end
        end
    end
    u1 = A(1); u2 = A(2); u3 = A(3); u4 = A(4);
    uy = (1 - xdif)*(1 - ydif)*u1 + xdif*(1 - ydif)*u2 + xdif*ydif*u3 + (1 - xdif)*ydif*u4;

    % 對應的換算距離也要交換
    dx = pos2dist(lat1(iy), lon1(ix), lat1(iy), lon1(ix+1), 1) * 1000;
    dy = pos2dist(lat1(iy), lon1(ix), lat1(iy+1), lon1(ix), 1) * 1000;

    xpos2 = (vx * dtuv) / dx * (lon1(ix+1) - lon1(ix)) + xpos1;  % v0 用於 x
    ypos2 = (uy * dtuv) / dy * (lat1(iy+1) - lat1(iy)) + ypos1;  % u0 用於 y
end
end
