Ignore:
Timestamp:
Feb 27, 2011, 10:41:07 PM (13 years ago)
Author:
sommeria
Message:

bug fixes to deal with volumes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r187 r207  
    103103                        text_displ_4='';
    104104                        for icell=1:numel(CellVarIndex)%look for all physical fields
    105                             if NbDim(icell)==2 % select 2D field
     105                            if NbDim(icell)>=2 % select 2D field
    106106                                if  isfield(Field,'Mesh') && ~isempty(Field.Mesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
    107107                                    eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
     
    169169%                     end
    170170                    if strcmp(text_displ_1,'')
    171                         text_displ_1=['x=' num2str(xy(1,1),3) ',y=' num2str(xy(1,2),3) ','];
    172                     end
    173                     if isfield(Field,'PlaneCoord') && isfield(Field,'ZIndex')
    174                         text_displ_1=[text_displ_1 ' z=' num2str(Field.PlaneCoord(Field.ZIndex,3))]; %TODO: generaliser au cas avec angle
     171                        text_displ_1=['x=' num2str(xy(1,1),3) ',y=' num2str(xy(1,2),3) ',']; 
     172                        z=[];
     173                        if isfield(Field,'PlaneCoord') && isfield(Field,'ZIndex')
     174                            ZIndex=Field.ZIndex;
     175                            if size(Field.PlaneCoord)>=[ZIndex 3]
     176                            z=Field.PlaneCoord(ZIndex,3);
     177                            if isfield(Field,'PlaneAngle')
     178                                om=norm(Field.PlaneAngle(ZIndex,:));%norm of rotation angle in radians
     179                                OmAxis=Field.PlaneAngle(ZIndex,:)/om; %unit vector marking the rotation axis
     180                                cos_om=cos(pi*om/180);
     181                                sin_om=sin(pi*om/180);
     182                                coeff=OmAxis(3)*(1-cos_om);
     183                                norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
     184                                norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
     185                                norm_plane(3)=OmAxis(3)*coeff+cos_om;
     186                                Z0=norm_plane*Field.PlaneCoord(ZIndex,:)'/norm_plane(3);
     187                                z=Z0-norm_plane(1)*xy(1,1)/norm_plane(3)-norm_plane(2)*xy(1,2)/norm_plane(3);
     188                            end
     189                            end
     190                        end
     191                        if ~isempty(z)
     192                            text_displ_1=[text_displ_1 ' z=' num2str(z,3)]; %TODO: generaliser au cas avec angle
     193                        end
    175194                    end
    176195                    %coordinate transform if proj_coord differs from menu_coord A REVOIR
Note: See TracChangeset for help on using the changeset viewer.