Ignore:
Timestamp:
Mar 30, 2020, 3:48:19 PM (4 years ago)
Author:
sommeria
Message:

various updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r1077 r1078  
    985985
    986986%-----------------------------------------------------------------
    987 %project on a plane
    988 % AJOUTER flux,circul,error
     987% proj_plane: project on a plane defined by the structure ObjectData containing:
     988%    .Type : = 'plane'
     989%    .ProjMode (mode of projection) = 'projection'|'interp_lin'|'interp_tps' ;
     990%    .CoordUnit: (for instance 'px','cm') units for the coordinates defining the plane  (the program checks that it fits with the unit of the input Field)
     991%    .Angle : angles of rotation of the plane expressed in degrees. The first element
     992%         ObjectData.Angle(1) represents a rotation in the plane (x,y) (around the
     993%         vertical axis), which can be followed by a rotation with angle ObjectData.Angle(2) around the new (rotated) x axis.
     994%    .Coord(1,3): coordinates (x,y,z) of the origin of the new coordinates in the projection plane;
     995%    .DX,.DY,.DZ : increments along each coordinate for the projected data (for 'interp_lin' and 'interp_tps')
     996%    .RangeX,RangeY: vectors with two elements defining the lower and upper bounds of the respectively X and Y coordinates in the projection plane
     997%    .RangeInterp: maximum distance of interpolation from the known data. Interpolation yields NaN beyond this distance.
     998
     999% TODO: AJOUTER flux,circul,error
    9891000function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
    9901001%-----------------------------------------------------------------
    9911002
    992 %% rotation angles
     1003%% rotation matrix
    9931004PlaneAngle=[0 0];
    9941005norm_plane=[0 0 1];
    995 %cos_om=1;
    996 %sin_om=0;
    9971006test90x=0;%=1 for 90 degree rotation alround x axis
    9981007test90y=0;%=1 for 90 degree rotation alround y axis
    999 % if strcmp(ObjectData.Type,'plane_z')
    1000 %     Delta_x=ObjectData.Coord(2,1)-ObjectData.Coord(1,1);
    1001 %     Delta_y=ObjectData.Coord(2,2)-ObjectData.Coord(1,2);
    1002 %     Delta_mod=sqrt(Delta_x*Delta_x+Delta_y*Delta_y);
    1003 %     ObjectData.Angle=[0 0 0];
    1004 %     ObjectData.Angle(1)=90*Delta_x/Delta_mod;
    1005 %     ObjectData.0(2)=90*Delta_y/Delta_mod;
    1006 % end
     1008
    10071009if isfield(ObjectData,'Angle')
    10081010    checkM2=0;
     
    10141016    if PlaneAngle==0
    10151017        PlaneAngle=[0 0];
    1016     end
    1017     %     om=norm(PlaneAngle);%norm of rotation angle in radians
    1018     %     OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
    1019     %     cos_om=cos(om);
    1020     %     sin_om=sin(om);
    1021     %     coeff=OmAxis(3)*(1-cos_om);
    1022     %     %components of the unity vector norm_plane normal to the projection plane
    1023     %     norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    1024     %     norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    1025     %     norm_plane(3)=OmAxis(3)*coeff+cos_om;
    1026    
     1018    end   
    10271019    M1=[cos(PlaneAngle(1)) -sin(PlaneAngle(1)) 0;sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
    10281020    M=M1;
     
    10311023        M=M1*M2;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2)
    10321024    end
    1033     norm_plane=M*[0 0 1]';
    1034    
     1025    norm_plane=M*[0 0 1]'; 
    10351026end
    10361027testangle=~isequal(PlaneAngle,[0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane
     
    14251416                %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane
    14261417                Phi=PlaneAngle(1);
    1427                 if testangle && ~test90y && ~test90x;%=1 for slanted plane
     1418                if testangle && ~test90y && ~test90x %=1 for slanted plane
    14281419                    new_XI=XI *cos(Phi) - YI* sin(Phi)+ObjectData.Coord(1);
    14291420                    YI=XI *sin(Phi) + YI *cos(Phi)+ObjectData.Coord(2);
Note: See TracChangeset for help on using the changeset viewer.