Changeset 212 for trunk/src/set_object.m


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

bugs on set_object and proj_field repaired , new plane angle definition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.