Changeset 935 for trunk/src/proj_field.m


Ignore:
Timestamp:
Mar 28, 2016, 9:15:18 PM (8 years ago)
Author:
sommeria
Message:

various improvments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r933 r935  
    951951PlaneAngle=[0 0 0];
    952952norm_plane=[0 0 1];
    953 cos_om=1;
    954 sin_om=0;
     953%cos_om=1;
     954%sin_om=0;
    955955test90x=0;%=1 for 90 degree rotation alround x axis
    956956test90y=0;%=1 for 90 degree rotation alround y axis
     
    10521052    ProjData.CoordMesh=FieldData.CoordMesh;
    10531053end
    1054 error=0;%default
    1055 flux=0;
    1056 testfalse=0;
    1057 ListIndex={};
     1054%error=0;%default
     1055%flux=0;
     1056%testfalse=0;
     1057%ListIndex={};
    10581058
    10591059%% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
     
    13401340            if strcmp(ProjMode{icell},'interp_tps')
    13411341                Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex});
     1342               
     1343               
     1344                coord_x=Coord(:,1,:);% initial x coordinates
     1345            coord_y=Coord(:,2,:);% initial y coordinates
     1346            check3D=(numel(CellInfo{icell}.CoordIndex)==3);
     1347            if check3D
     1348                coord_z=Coord(:,3,:);
     1349            end
     1350           
     1351            % translate  initial coordinates to account for the new origin
     1352            coord_x=coord_x-ObjectData.Coord(1,1);
     1353            coord_y=coord_y-ObjectData.Coord(1,2);
     1354            if check3D
     1355                coord_z=coord_z-ObjectData.Coord(1,3);
     1356            end
     1357           
     1358            % selection of the vectors in the projection range (3D case)
     1359            if check3D &&  width > 0
     1360                %components of the unitiy vector normal to the projection plane
     1361                fieldZ=norm_plane(1)*coord_x + norm_plane(2)*coord_y+ norm_plane(3)*coord_z;% distance to the plane
     1362                indcut=find(abs(fieldZ) <= width);
     1363                for ivar=VarIndex
     1364                    VarName=FieldData.ListVarName{ivar};
     1365                    FieldData.(VarName)=FieldData.(VarName)(indcut);
     1366                end
     1367                coord_x=coord_x(indcut);
     1368                coord_y=coord_y(indcut);
     1369                coord_z=coord_z(indcut);
     1370            end
     1371           
     1372            %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane
     1373            Psi=PlaneAngle(1);
     1374            Theta=PlaneAngle(2);
     1375            Phi=PlaneAngle(3);
     1376            if testangle && ~test90y && ~test90x;%=1 for slanted plane
     1377                coord_X=(coord_x *cos(Phi) + coord_y* sin(Phi));
     1378                coord_Y=(-coord_x *sin(Phi) + coord_y *cos(Phi))*cos(Theta);
     1379                coord_Y=coord_Y+coord_z *sin(Theta);
     1380                coord_X=(coord_X *cos(Psi) - coord_Y* sin(Psi));%A VERIFIER
     1381                coord_Y=(coord_X *sin(Psi) + coord_Y* cos(Psi));
     1382            else
     1383                coord_X=coord_x;
     1384                coord_Y=coord_y;
     1385            end
     1386           
     1387            %restriction to the range of X and Y if imposed by the projection object
     1388
     1389               
     1390                Coord(:,1,:)=coord_X;% initial x coordinates
     1391            Coord(:,2,:)=coord_Y;% initial y coordinates
     1392               
     1393               
    13421394                NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps});
    13431395                SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
Note: See TracChangeset for help on using the changeset viewer.