Changeset 966 for trunk/src/proj_field.m
- Timestamp:
- Jul 9, 2016, 10:02:57 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r965 r966 552 552 return 553 553 end 554 CellInfo=CellInfo(NbDim ==2); %keep only the 2D cells554 CellInfo=CellInfo(NbDim>=2); %keep only the 2D cells 555 555 %%%%%% TODO: treat 1D fields: project as identity so that P o P=P for projection operation 556 556 cell_select=true(size(CellInfo)); … … 676 676 VarIndex=find(check_proj);% indices of the variables to be projected 677 677 678 %% identify vector components679 %testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors680 % if testU681 % UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};682 % VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};683 % vector_x=FieldData.(UName);684 % vector_y=FieldData.(VName);685 % end686 678 %identify error flag 687 679 errorflag=0; %default, no error flag … … 701 693 %case of unstructured coordinates 702 694 case 'scattered' 703 % XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};704 % YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};695 % XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 696 % YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 705 697 coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}); 706 698 coord_y=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); … … 813 805 case 'grid' %case of structured coordinates 814 806 if ~isequal(ObjectData.Type,'line')% exclude polyline 815 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; % 807 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; 808 return 809 end% 810 test_interp2=0;%default 811 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 812 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 813 AX=FieldData.(AXName);% set of x positions 814 AY=FieldData.(AYName);% set of y positions 815 AName=FieldData.ListVarName{VarIndex(1)}; 816 npxy=size(FieldData.(AName)); 817 if max(NbDim)==3 % 3D case 818 816 819 else 817 test_Amat=1;%image or 2D matrix818 test_interp2=0;%default819 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};820 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};821 eval(['AX=FieldData.' AXName ';']);% set of x positions822 eval(['AY=FieldData.' AYName ';']);% set of y positions823 AName=FieldData.ListVarName{VarIndex(1)};824 eval(['A=FieldData.' AName ';']);% scalar825 npxy=size(A);826 820 npx=npxy(2); 827 821 npy=npxy(1); … … 921 915 end 922 916 end 923 if ~isempty(ivar_U) && ~isempty(ivar_V) 924 vector_x =ProjData.(ProjData.ListVarName{ivar_U}); 925 ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V}); 926 ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V}); 927 end 917 end 918 if ~isempty(ivar_U) && ~isempty(ivar_V) 919 vector_x =ProjData.(ProjData.ListVarName{ivar_U}); 920 ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V}); 921 ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V}); 922 end 928 923 end 929 924 … … 961 956 % ObjectData.Angle=[0 0 0]; 962 957 % ObjectData.Angle(1)=90*Delta_x/Delta_mod; 963 % ObjectData. Angle(2)=90*Delta_y/Delta_mod;958 % ObjectData.0(2)=90*Delta_y/Delta_mod; 964 959 % end 965 960 if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 2])&& ~isequal(ObjectData.Angle,[0 0]) 966 961 test90y=0;%isequal(ObjectData.Angle,[0 90 0]); 967 962 PlaneAngle=(pi/180)*ObjectData.Angle; 968 % om=norm(PlaneAngle);%norm of rotation angle in radians969 % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis970 % cos_om=cos(om);971 % sin_om=sin(om);972 % coeff=OmAxis(3)*(1-cos_om);973 % %components of the unity vector norm_plane normal to the projection plane974 % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;975 % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;976 % norm_plane(3)=OmAxis(3)*coeff+cos_om;963 % om=norm(PlaneAngle);%norm of rotation angle in radians 964 % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis 965 % cos_om=cos(om); 966 % sin_om=sin(om); 967 % coeff=OmAxis(3)*(1-cos_om); 968 % %components of the unity vector norm_plane normal to the projection plane 969 % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 970 % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 971 % norm_plane(3)=OmAxis(3)*coeff+cos_om; 977 972 978 M2=[cos(PlaneAngle(2)) sin(PlaneAngle(2)) 0;-sin(PlaneAngle(2)) cos(PlaneAngle(2)) 0;0 0 1];979 M1=[1 0 0;0 cos(PlaneAngle(1)) sin(PlaneAngle(1));0 -sin(PlaneAngle(1)) cos(PlaneAngle(1))];980 M=M1*M2; 981 norm_plane=M*[0 0 1]';973 M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1]; 974 M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))]; 975 M=M2*M1;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2) 976 norm_plane=M*[0 0 1]'; 982 977 983 978 end … … 1648 1643 % determine the boundaries of the projected field, 1649 1644 % first find the 8 summits of the initial volume in the 1650 Angle=ObjectData.Angle*pi/180;1645 PlaneAngle=ObjectData.Angle*pi/180; 1651 1646 % new coordinates 1652 1647 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});%initial z coordinates … … 1660 1655 %Mrot_inv=rodrigues(-PlaneAngle); 1661 1656 newsummit=zeros(3,8);% initialize the rotated summit coordinates 1662 ObjectData.Coord=ObjectData.Coord'; 1663 if size(ObjectData.Coord, 2)<31657 ObjectData.Coord=ObjectData.Coord';% set ObjectData.Coord as a vertical vector 1658 if size(ObjectData.Coord,1)<3 1664 1659 ObjectData.Coord=[ObjectData.Coord; 0];%add z origin at z=0 by default 1665 1660 end 1666 M2=[cos(Angle(2)) sin(Angle(2)) 0;-sin(Angle(2)) cos(Angle(2)) 0;0 0 1]; 1667 M1=[1 0 0;0 cos(Angle(1)) sin(Angle(1));0 -sin(Angle(1)) cos(Angle(1))]; 1668 M=M1*M2; 1661 1662 M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1]; 1663 M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))]; 1664 M=M2*M1; 1669 1665 M_inv=inv(M); 1670 1666
Note: See TracChangeset
for help on using the changeset viewer.