Changeset 212


Ignore:
Timestamp:
Mar 2, 2011, 10:45:33 PM (13 years ago)
Author:
sommeria
Message:

bugs on set_object and proj_field repaired , new plane angle definition

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r206 r212  
    949949sin_om=0;
    950950if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 3])&& ~isequal(ObjectData.Angle,[0 0 0])
    951     PlaneAngle=ObjectData.Angle;
     951    PlaneAngle=(pi/180)*ObjectData.Angle;
    952952    om=norm(PlaneAngle);%norm of rotation angle in radians
    953953    OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
    954     cos_om=cos(pi*om/180);
    955     sin_om=sin(pi*om/180);
     954    cos_om=cos(om);
     955    sin_om=sin(om);
    956956    coeff=OmAxis(3)*(1-cos_om);
    957957    %components of the unity vector norm_plane normal to the projection plane
     
    14491449            if NbDim==2 %2D case
    14501450                [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
    1451                 XIMA=ObjectData.Coord(1,1)+(X)*cos(Phi)-Y*sin(Phi);%corresponding coordinates in the original image
    1452                 YIMA=ObjectData.Coord(1,2)+(X)*sin(Phi)+Y*cos(Phi);
     1451                XIMA=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-Y*sin(PlaneAngle(3));%corresponding coordinates in the original image
     1452                YIMA=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+Y*cos(PlaneAngle(3));
    14531453                XIMA=(XIMA-minAX)/DXinit+1;% image index along x
    14541454                YIMA=(-YIMA+maxAY)/DYinit+1;% image index along y
     
    15361536        UName=FieldData.ListVarName{ivar_U};
    15371537        VName=FieldData.ListVarName{ivar_V};   
    1538         eval(['ProjData.' UName  '=cos(Phi)*ProjData.' UName '+ sin(Phi)*ProjData.' VName ';'])
    1539         eval(['ProjData.' VName  '=cos(Theta)*(-sin(Phi)*ProjData.' UName '+ cos(Phi)*ProjData.' VName ');'])
     1538        eval(['ProjData.' UName  '=cos(PlaneAngle(3))*ProjData.' UName '+ sin(PlaneAngle(3))*ProjData.' VName ';'])
     1539        eval(['ProjData.' VName  '=cos(Theta)*(-sin(PlaneAngle(3))*ProjData.' UName '+ cos(PlaneAngle(3))*ProjData.' VName ');'])
    15401540        if ~isempty(ivar_W)
    15411541            WName=FieldData.ListVarName{ivar_W};
  • trunk/src/set_object.m

    r206 r212  
    210210        end
    211211    end 
    212     if isfield(data,'Phi')
    213         if ~ischar(handles.Phi)
    214             data.DY=num2str(data.Phi,3);
    215         end
    216          set(handles.Phi,'String',data.Phi)
    217     end
    218     if isfield(data,'Theta')
    219         if ~ischar(handles.Theta)
    220             data.DY=num2str(data.Theta,3);
    221         end
    222         set(handles.Theta,'String',data.Theta)
    223     end
    224     if isfield(data,'Psi')
    225          if ~ischar(handles.Psi)
    226             data.DY=num2str(data.Psi,3);
    227         end
    228          set(handles.Psi,'String',data.Psi)
    229     end 
     212    if isfield(data,'Angle') && isequal(numel(data.Angle),3)
     213         set(handles.Phi,'String',num2str(data.Angle(1)))
     214         set(handles.Theta,'String',num2str(data.Angle(2)))
     215         set(handles.Psi,'String',num2str(data.Angle(3)))
     216    end
    230217    if isfield(data,'DZ')
    231218        if ~ischar(handles.DZ)
     
    402389        set(handles.YObject,'TooltipString',['YObject:  y coordinate of the ' ObjectStyle ' centre'])
    403390    case {'plane'} 
    404         set(handles.Phi,'Visible','on')
     391        set(handles.Psi,'Visible','on')
    405392        set(handles.XMin,'Visible','on')
    406393        set(handles.XMax,'Visible','on')
     
    412399        if test3D
    413400            set(handles.Theta,'Visible','on')
    414             set(handles.Psi,'Visible','on')
     401            set(handles.Phi,'Visible','on')
    415402            set(handles.ZMax,'Visible','on')
    416403        end
     
    426413        end
    427414     case {'volume'} 
    428         set(handles.Phi,'Visible','on')
    429415        set(handles.XMin,'Visible','on')
    430416        set(handles.XMax,'Visible','on')
     
    433419        set(handles.XObject,'TooltipString',['XObject:  x coordinate of the axis origin for the ' ObjectStyle])
    434420        set(handles.YObject,'TooltipString',['YObject:  y coordinate of the axis origin for the ' ObjectStyle])
    435 %         if test3D
    436             set(handles.Theta,'Visible','on')
    437             set(handles.Psi,'Visible','on')
    438             set(handles.ZMin,'Visible','on')
    439             set(handles.ZMax,'Visible','on')
    440 %         end
     421        set(handles.Phi,'Visible','on')
     422        set(handles.Theta,'Visible','on')
     423        set(handles.Psi,'Visible','on')
     424        set(handles.ZMin,'Visible','on')
     425        set(handles.ZMax,'Visible','on')
    441426        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
    442427            set(handles.DX,'Visible','on')
     
    461446function update_slider(hObject, eventdata,handles)
    462447%rotation angles
    463 Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
    464 Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
    465 
    466 %components of the unitiy vector normal to the projection plane
    467 NormVec_X=-sin(Phi)*sin(Theta);
    468 NormVec_Y=cos(Phi)*sin(Theta);
    469 NormVec_Z=cos(Theta);
     448PlaneAngle(1)=str2num(get(handles.Phi,'String'));%first  angle in degrees
     449PlaneAngle(2)=str2num(get(handles.Theta,'String'));%second  angle in degrees
     450PlaneAngle(3)=str2num(get(handles.Psi,'String'));%second  angle in degrees
     451om=norm(PlaneAngle);%norm of rotation angle in radians
     452OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
     453cos_om=cos(pi*om/180);
     454sin_om=sin(pi*om/180);
     455coeff=OmAxis(3)*(1-cos_om);
     456%components of the unity vector norm_plane normal to the projection plane
     457norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
     458norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
     459norm_plane(3)=OmAxis(3)*coeff+cos_om;
    470460huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
    471461UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    472462if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z')
    473     Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z);
     463    Z=norm_plane(1)*(UvData.X)+norm_plane(2)*(UvData.Y)+norm_plane(3)*(UvData.Z);
    474464    set(handles.z_slider,'Min',min(Z))
    475465    set(handles.z_slider,'Max',max(Z))
     
    620610end
    621611if isfield(s,'Phi')
    622     set(handles.Phi,'String',s.Phi)
    623 end
    624 if isfield(s,'Theta')
    625     set(handles.Theta,'String',s.Theta)
    626 end
    627 if isfield(s,'Psi')
    628     set(handles.Psi,'String',s.Psi)
    629 end
     612    set(handles.Psi,'String',s.Phi)%old definition
     613end
     614if isfield(s,'Angle')&& isequal(numel(s.Angle),3)
     615    set(handles.Phi,'String',s.Angle(1))
     616    set(handles.Theta,'String',s.Angle(2))
     617    set(handles.Psi,'String',s.Angle(3))
     618end
     619% if isfield(s,'Psi')
     620%     set(handles.Psi,'String',s.Psi)
     621% end
    630622
    631623if isfield(s,'DX')
     
    860852function z_slider_Callback(hObject, eventdata, handles)
    861853%---------------------------------------------------------
    862 %A ADAPTER
    863854Z_value=get(handles.z_slider,'Value');
    864 
    865855%rotation angles
    866 Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
    867 Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
    868 
    869 %components of the unity vector normal to the projection plane
    870 NormVec_X=-sin(Phi)*sin(Theta);
    871 NormVec_Y=cos(Phi)*sin(Theta);
    872 NormVec_Z=cos(Theta);
     856PlaneAngle(1)=str2num(get(handles.Phi,'String'));%first  angle in degrees
     857PlaneAngle(2)=str2num(get(handles.Theta,'String'));%second  angle in degrees
     858PlaneAngle(3)=str2num(get(handles.Psi,'String'));%second  angle in degrees
     859om=norm(PlaneAngle);%norm of rotation angle in radians
     860OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
     861cos_om=cos(pi*om/180);
     862sin_om=sin(pi*om/180);
     863coeff=OmAxis(3)*(1-cos_om);
     864%components of the unity vector norm_plane normal to the projection plane
     865norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
     866norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
     867norm_plane(3)=OmAxis(3)*coeff+cos_om;
    873868
    874869%set new plane position and update graph
    875 set(handles.XObject,'String',num2str(NormVec_X*Z_value,4))
    876 set(handles.YObject,'String',num2str(NormVec_Y*Z_value,4))
    877 set(handles.ZObject,'String',num2str(NormVec_Z*Z_value,4))
     870set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4))
     871set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4))
     872set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4))
    878873PLOT_Callback(hObject, eventdata, handles)
    879874%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.