%extend the Posecells one unit in each direction (max supported at the moment)
% work out the weight contribution to the NE cell from the SW, NW, SE cells
% given vtrans and the direction
% weight_sw = v * cos(th) * v * sin(th)
% weight_se = (1 - v * cos(th)) * v * sin(th)
% weight_nw = (1 - v * sin(th)) * v * sin(th)
% weight_ne = 1 - weight_sw - weight_se - weight_nw
% think in terms of NE divided into 4 rectangles with the sides
% given by vtrans and the angle
pca_new=zeros(PC_DIM_XY+2);
pca_new(2:end-1,2:end-1) = pca90;
weight_sw = vtrans^2 *cos(dir90) * sin(dir90);
weight_se = vtrans*sin(dir90) - vtrans^2 *cos(dir90) * sin(dir90);
weight_nw = vtrans*cos(dir90) - vtrans^2 *cos(dir90) * sin(dir90);
weight_ne = 1.0 - weight_sw - weight_se - weight_nw;
% circular shift and multiple by the contributing weight
% copy those shifted elements for the wrap around
pca_new = pca_new.*weight_ne + circshift(pca_new, [0 1]).*weight_nw + circshift(pca_new, [1 0]).*weight_se + circshift(pca_new, [1 1]).*weight_sw;
pca90 = pca_new(2:end-1,2:end-1);
pca90(2:end,1) = pca90(2:end,1) + pca_new(3:end-1,end);
pca90(1,2:end) = pca90(1,2:end) + pca_new(end,3:end-1);
pca90(1,1) = pca90(1,1) + pca_new(end:end);
% unrotate the pose cell xy layer
Posecells(:,:,dir_pc) = rot90(pca90, 4 - floor(dir * 2/pi));
I don't konw the funciton of these codes.
I don't konw the funciton of these codes.