From 976a540e5872855054fa8d714979eb2f2f49cfe0 Mon Sep 17 00:00:00 2001 From: Peter Reischig <peter.reischig@esrf.fr> Date: Thu, 28 Mar 2013 13:23:48 +0100 Subject: [PATCH] Substituted 'repmat' command. Signed-off-by: Peter Reischig <peter.reischig@esrf.fr> --- zUtil_Geo/gtGeoPointProjectionsOnDetector.m | 6 +++--- zUtil_Geo/gtGeoProjectedSampleEnvelope.m | 18 +++++++++--------- zUtil_Geo/gtGeoScattVecFromDiffVec.m | 20 +++++++++++++------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/zUtil_Geo/gtGeoPointProjectionsOnDetector.m b/zUtil_Geo/gtGeoPointProjectionsOnDetector.m index b47804b3..27738c27 100644 --- a/zUtil_Geo/gtGeoPointProjectionsOnDetector.m +++ b/zUtil_Geo/gtGeoPointProjectionsOnDetector.m @@ -31,13 +31,13 @@ function projUV = gtGeoPointProjectionsOnDetector(labXYZ,projvecs,labgeo) % Multiplication factor for projection vector -mf = (((labgeo.detorig-labXYZ)*labgeo.detnorm')./(projvecs*labgeo.detnorm')); +mf = (((labgeo.detorig - labXYZ) * labgeo.detnorm') ./ (projvecs * labgeo.detnorm')); % Projected points in Lab coordinates X,Y,Z -projXYZ = repmat(labXYZ,size(projvecs,1),1) + repmat(mf,1,3).*projvecs ; +projXYZ = labXYZ(ones(size(projvecs,1),1),:) + [mf mf mf].*projvecs ; % Projected points in Scintillator coordinates U,V -projUV = (projXYZ-repmat(labgeo.detorig,size(projvecs,1),1))*... +projUV = (projXYZ - labgeo.detorig(ones(size(projvecs,1),1),:))*... [labgeo.detdiru'/labgeo.pixelsizeu, labgeo.detdirv'/labgeo.pixelsizev]; % Check if out of detector U,V range or projection is away from detector diff --git a/zUtil_Geo/gtGeoProjectedSampleEnvelope.m b/zUtil_Geo/gtGeoProjectedSampleEnvelope.m index a8daaf24..f32d36e0 100644 --- a/zUtil_Geo/gtGeoProjectedSampleEnvelope.m +++ b/zUtil_Geo/gtGeoProjectedSampleEnvelope.m @@ -82,17 +82,17 @@ tanp(5:6,:) = gtMathsCircleTangents(spdirvtop,topcenter,labgeo.samenvrad,labgeo. tanp(7:8,:) = gtMathsCircleTangents(spdirvbot,botcenter,labgeo.samenvrad,labgeo.rotdir); % project the tangent points onto the pseudo detector from the spot: -tanpproj(1,:) = gtMathsProjectPointsOnPlane(tanp(1,:),tanp(1,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(2,:) = gtMathsProjectPointsOnPlane(tanp(2,:),tanp(2,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(3,:) = gtMathsProjectPointsOnPlane(tanp(3,:),tanp(3,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(4,:) = gtMathsProjectPointsOnPlane(tanp(4,:),tanp(4,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(5,:) = gtMathsProjectPointsOnPlane(tanp(5,:),tanp(5,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(6,:) = gtMathsProjectPointsOnPlane(tanp(6,:),tanp(6,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(7,:) = gtMathsProjectPointsOnPlane(tanp(7,:),tanp(7,:)-spXYZ,detorigmirr,detnormmirr); -tanpproj(8,:) = gtMathsProjectPointsOnPlane(tanp(8,:),tanp(8,:)-spXYZ,detorigmirr,detnormmirr); +tanpproj(1,:) = gtMathsProjectPointsOnPlane(tanp(1,:), tanp(1,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(2,:) = gtMathsProjectPointsOnPlane(tanp(2,:), tanp(2,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(3,:) = gtMathsProjectPointsOnPlane(tanp(3,:), tanp(3,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(4,:) = gtMathsProjectPointsOnPlane(tanp(4,:), tanp(4,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(5,:) = gtMathsProjectPointsOnPlane(tanp(5,:), tanp(5,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(6,:) = gtMathsProjectPointsOnPlane(tanp(6,:), tanp(6,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(7,:) = gtMathsProjectPointsOnPlane(tanp(7,:), tanp(7,:)-spXYZ, detorigmirr, detnormmirr); +tanpproj(8,:) = gtMathsProjectPointsOnPlane(tanp(8,:), tanp(8,:)-spXYZ, detorigmirr, detnormmirr); % transform the tangent points Lab coordinates into the pseudo detector coordinates: -tanpprojvec = tanpproj - repmat(detorigmirr,8,1) ; +tanpprojvec = tanpproj - detorigmirr(ones(8,1),:); tanpprojU = (tanpprojvec*detdirumirr')/labgeo.pixelsizeu; tanpprojV = (tanpprojvec*detdirvmirr')/labgeo.pixelsizev; diff --git a/zUtil_Geo/gtGeoScattVecFromDiffVec.m b/zUtil_Geo/gtGeoScattVecFromDiffVec.m index b6575071..cc16a9b2 100644 --- a/zUtil_Geo/gtGeoScattVecFromDiffVec.m +++ b/zUtil_Geo/gtGeoScattVecFromDiffVec.m @@ -2,28 +2,34 @@ % FUNCTION scattvec = gtGeoScattVecFromDiffVec(diffvec,beamdir) % % Given a set of diffraction vectors with their Lab coordinates X,Y,Z and -% the incoming beam direction, the function returns the corresponding -% unit scattering vectors (plane normals). +% the incoming beam direction, the function returns the Lab coordinates +% of the corresponding unit scattering vectors (plane normals) % The diffraction vectors indicate the direction of the diffracted beam % paths. The scattering vectors are computed as: diffvec - beamdir . % -% INPUT diffvec - Lab coordinates X,Y,Z of a set of diffraction vectors (n,3) +% INPUT diffvec - Lab coordinates X,Y,Z of a set of diffraction vectors; +% unit vectors! (n,3) % beamdir - Lab coordinates X,Y,Z of the incoming beam direction; -% unit vector (1,3) +% unit vector! (1,3) % % OUTPUT scattvec - Lab coordinates of the normalised scattering vectors; -% (n,3) +% unit vectors (n,3) % +% !!! it probably doesn't matter if it's the Lab, but has to be the same +% reference for all + function scattvec = gtGeoScattVecFromDiffVec(diffvec,beamdir) % Scattering vectors -scattvec = diffvec - repmat(beamdir,size(diffvec,1),1); +scattvec = diffvec - beamdir(ones(size(diffvec,1),1),:); % Normalise scattvec-s: -snorm = sqrt(scattvec(:,1).^2 + scattvec(:,2).^2 + scattvec(:,3).^2) ; +snorm = sqrt(scattvec(:,1).^2 + scattvec(:,2).^2 + scattvec(:,3).^2) ; scattvec(:,1) = scattvec(:,1)./snorm ; scattvec(:,2) = scattvec(:,2)./snorm ; scattvec(:,3) = scattvec(:,3)./snorm ; + +end \ No newline at end of file -- GitLab