Changeset 936 for trunk/src


Ignore:
Timestamp:
Mar 30, 2016, 11:01:43 PM (8 years ago)
Author:
sommeria
Message:

projection tps with angle

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r935 r936  
    13421342               
    13431343               
    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                
    13941344                NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps});
    13951345                SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
     1346                checkUV=0;
    13961347                if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
    13971348                    FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x_tps}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y_tps}));
    1398                 end
     1349                    checkUV=1;
     1350                end
     1351               
     1352                %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane
     1353                Psi=PlaneAngle(1);
     1354                Theta=PlaneAngle(2);
     1355                Phi=PlaneAngle(3);
     1356                if testangle && ~test90y && ~test90x;%=1 for slanted plane
     1357                    new_XI=XI*cos(Phi) - YI*sin(Phi)+ObjectData.Coord(1);
     1358                    YI=XI *sin(Phi) + YI *cos(Phi)+ObjectData.Coord(2);
     1359                    XI=new_XI;
     1360                    %                 if checkUV
     1361                    %                     UValue=cos(Phi)*FieldVar(:,:,1)+ sin(Phi)*FieldVar(:,:,2);
     1362                    %                     FieldVar(:,:,2)=-sin(Phi)*FieldVar(:,:,1)+ cos(Phi)*FieldVar(:,:,2);
     1363                    %                     FieldVar(:,:,1)=UValue;
     1364                    %                 end
     1365                end
     1366               
    13991367                % interpolate data using thin plate spline
    14001368                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));
  • trunk/src/uvmat.m

    r935 r936  
    36123612end
    36133613
    3614 %% calculate tps coefficients if needed
    3615 UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
    3616 
    36173614%% get bounds and dimensions of the input field
    36183615UvData.Field=find_field_bounds(UvData.Field);
    36193616testnewseries=UvData.NewSeries;
    36203617UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
     3618
     3619
     3620%% calculate tps coefficients if needed
     3621UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
    36213622
    36223623%% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
Note: See TracChangeset for help on using the changeset viewer.