Skip to content
Snippets Groups Projects
gtDiffPlaneNormInLab.m 1.92 KiB
%
% FUNCTION plnorm=gtDiffPlaneNormInLab(scXA,scYA,scXB,scYB,rottodet,tiltY,tiltZ,rotx,sorZ)
%
% Given the Scintillator coordinates of pairs of diffraction spots, 
% computes the diffracting plane normals they correspond to, according to
% tilts and rotation axis to detector (scintillator) distance.
%
%   LAB system is right-handed and defined as: 
%     origin X = on the rotation axis, positive towards the camera
%     origin Y = on the rotation axis
%     origin Z = floor(parameters.acq.ydet/2) in the middle of the central
%                pixel row of the image, positive upwards
% 
% INPUT  scXA = coloumn vector of X coordinates on the Scintillator of point A (pixels or mm-s)
%        scYA = coloumn vector of Y coordinates on the Scintillator of point A (pixels or mm-s)
%        scXB = coloumn vector of X coordinates on the Scintillator of point B (pixels or mm-s)
%        scYB = coloumn vector of Y coordinates on the Scintillator of point B (pixels or mm-s)
%        rottodet = rotation axis to detector (scintillator) distance at rotx,sorZ (pixels or mm-s)
%        /scX,scY,rottodet have to be in the same units; e.g. pixels or mm-s/
%        tiltY = tilt around axis Y in Lab system (in degrees)
%        tiltZ = tilt around axis Z in Lab system (in degrees)
%        rotx = location of rotation axis in the images (X coord. in pixels)
%        sorZ = Z=0 location in the images (Y coord. in pixels at the rotation axis) 
%
% OUTPUT plnorm = coloumn vector of plane normals of size(plnorm)=[n,3]
%
%


function plnorm=gtDiffPlaneNormInLab(scXA,scYA,scXB,scYB,rottodet,tiltY,tiltZ,rotx,sorZ)

dv= gtDiffVecInLab(scXA,scYA,scXB,scYB,rottodet,tiltY,tiltZ,rotx,sorZ); % diffraction vector

plv= dv-repmat([1 0 0],size(dv,1),1); % plane vector

plvnorm=sqrt(plv(:,1).^2+plv(:,2).^2+plv(:,3).^2) ; % norm of plane vectors

plnorm(:,1)= plv(:,1)./plvnorm ; % normalized plane vectors
plnorm(:,2)= plv(:,2)./plvnorm ;
plnorm(:,3)= plv(:,3)./plvnorm ;

end