Skip to content
Snippets Groups Projects
Commit eb1c79ee authored by Yoann Guilhem's avatar Yoann Guilhem Committed by Nicola Vigano
Browse files

Cleaned and optimized some rendering functions

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@948 4c865b51-4357-4376-afb4-474e03ccb993
parent 0b00e11f
No related branches found
No related tags found
No related merge requests found
......@@ -39,28 +39,26 @@ hkil = reflection;
for i = 1:size(hkil,1)
all_hkils = [all_hkils ; gtGetReflections(hkil(i,:), parameters.cryst(phaseid).spacegroup)];
end
% normalise hkls vector
% going to cartesian reciprocal space + normalisation of the cartesian
% space
for i=1:size(all_hkils)
all_hkls(i,1)= all_hkils(i,1) + 0.5 * all_hkils(i,2);
all_hkls(i,2)= 3^0.5/2 *all_hkils(i,2);
all_hkls(i,3)= all_hkils(i,4);
all_hkls(:, 1) = all_hkils(:, 1) + 0.5 * all_hkils(:, 2);
all_hkls(:, 2) = sqrt(3)/2 * all_hkils(:, 2);
all_hkls(:, 3) = all_hkils(:, 4);
all_hkls(i,1)=all_hkls(i,1)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(i,2)=all_hkls(i,2)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(i,3)=all_hkls(i,3)/parameters.cryst(phaseid).latticepar(3);
end
all_hkls(:, 1) = all_hkls(:, 1)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(:, 2) = all_hkls(:, 2)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(:, 3) = all_hkls(:, 3)/parameters.cryst(phaseid).latticepar(3);
% normalise hkls vector
tmp = sqrt(sum((all_hkls.*all_hkls),2));
normalised_hkls = all_hkls./(repmat(tmp,1,3));
% unification des notations pour la suite
all_hkls = [];
all_hkls = all_hkils;
a_axis = zeros(size(r_vectors, 1), 4);
a_axis(:, 1) = r_vectors(:, 1);
for i=1:size(r_vectors,1)
crys2sam = Rod2g(r_vectors(i,2:4));
all_normals = (crys2sam * normalised_hkls')';
a_axis(i,1)=r_vectors(i,1);
if all_normals(6,1)>=0
a_axis(i,2)=all_normals(6,1);
a_axis(i,3)=all_normals(6,2);
......
......@@ -39,28 +39,26 @@ hkil = reflection;
for i = 1:size(hkil,1)
all_hkils = [all_hkils ; gtGetReflections(hkil(i,:), parameters.cryst(phaseid).spacegroup)];
end
% normalise hkls vector
% going to cartesian reciprocal space + normalisation of the cartesian
% space
for i=1:size(all_hkils)
all_hkls(i,1)= all_hkils(i,1) + 0.5 * all_hkils(i,2);
all_hkls(i,2)= 3^0.5/2 *all_hkils(i,2);
all_hkls(i,3)= all_hkils(i,4);
all_hkls(:, 1) = all_hkils(:, 1) + 0.5 * all_hkils(:, 2);
all_hkls(:, 2) = sqrt(3)/2 * all_hkils(:, 2);
all_hkls(:, 3) = all_hkils(:, 4);
all_hkls(i,1)=all_hkls(i,1)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(i,2)=all_hkls(i,2)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(i,3)=all_hkls(i,3)/parameters.cryst(phaseid).latticepar(3);
end
all_hkls(:, 1) = all_hkls(:, 1)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(:, 2) = all_hkls(:, 2)*2/(sqrt(3)*parameters.cryst(phaseid).latticepar(1));
all_hkls(:, 3) = all_hkls(:, 3)/parameters.cryst(phaseid).latticepar(3);
% normalise hkls vector
tmp = sqrt(sum((all_hkls.*all_hkls),2));
normalised_hkls = all_hkls./(repmat(tmp,1,3));
% unification des notations pour la suite
all_hkls = [];
all_hkls = all_hkils;
c_axis = zeros(size(r_vectors, 1), 4);
c_axis(:, 1) = r_vectors(:, 1);
for i=1:size(r_vectors,1)
crys2sam = Rod2g(r_vectors(i,2:4));
all_normals = (crys2sam * normalised_hkls')';
c_axis(i,1)=r_vectors(i,1);
if all_normals(2,3)>=0
c_axis(i,2)=all_normals(2,1);
c_axis(i,3)=all_normals(2,2);
......
......@@ -66,10 +66,6 @@ else
symm = {tmp.g};
end
% Create the map
M = length(r_vectors);
map = zeros(M, 3);
% Get sample to crystal rotation matrices
sam2crys = gtMathsRod2RotMat(r_vectors);
......
......@@ -94,7 +94,7 @@ if ~isempty(poles)
dum=find(poles(:,2)>-sin(searchR) & poles(:,2)<poles(:,1)+(sqrt(2)*sin(searchR)) & poles(:,3)>poles(:,1)-(sqrt(2)*sin(searchR)));
poles=poles(dum, :);
weights=weights(dum);
valid_poles_weight=sum(weights(find(poles(:,2)>=0 & poles(:,2)<=poles(:,1) & poles(:,3)>=poles(:,1))));
valid_poles_weight=sum(weights(poles(:,2)>=0 & poles(:,2)<=poles(:,1) & poles(:,3)>=poles(:,1)));
total_solid_angle=pi/12;
elseif strcmp(app.range, 'phi90')
% for a 90 degree section of the pole figure
......@@ -103,7 +103,7 @@ if ~isempty(poles)
dum=find(poles(:,1)>-sin(searchR) & poles(:,2)>-sin(searchR) & poles(:,3)>cos(psimax)-sin(searchR));
poles=poles(dum, :);
weights=weights(dum);
valid_poles_weight=sum(weights(find(poles(:,1)>=0 & poles(:,2)>=0 & poles(:,3)>=0)));
valid_poles_weight=sum(weights(poles(:,1)>=0 & poles(:,2)>=0 & poles(:,3)>=0));
total_solid_angle=pi/2;
elseif strcmp(app.range, 'phi360')
% for 360 pole figure - reduce only using psi
......@@ -112,7 +112,7 @@ if ~isempty(poles)
dum=find(poles(:,3)>cos(psimax)-sin(searchR));
poles=poles(dum,:);
weights=weights(dum);
valid_poles_weight=sum(weights(find(poles(:,3)>=0)));
valid_poles_weight=sum(weights(poles(:,3)>=0));
total_solid_angle=2*pi;
else
disp('unrecognised plot range :-(')
......@@ -121,9 +121,9 @@ if ~isempty(poles)
% analyse the pole data
i=1;j=1;
ii=1;
for phi=[0:inc:phimax phimax] %around z-axis
j=1;
jj=1;
for psi=[0:inc:psimax psimax] % out from z-axis
z=cos(psi);
......@@ -132,13 +132,13 @@ if ~isempty(poles)
test_normal=[x y z];
angle_dev = acos((dot(poles, repmat(test_normal, size(poles,1), 1), 2)));
density(i,j)=sum(weights(find(angle_dev<searchR)));
j=j+1;
density(ii,jj)=sum(weights(angle_dev<searchR));
jj=jj+1;
end
if mod(i, round(length([0:inc:phimax phimax])/10))==0
fprintf('%d percent done\n', round(100*i/length([0:inc:phimax phimax])))
if mod(ii, round(length([0:inc:phimax phimax])/10))==0
fprintf('%d percent done\n', round(100*ii/length([0:inc:phimax phimax])))
end
i=i+1;
ii=ii+1;
end
% before normalising, save raw density values
......@@ -237,8 +237,8 @@ if app.plot_figure
% permute
uvw_poles_hex2=[];
for i = 1:size(uvw_poles_hex,1)
uvw_poles_hex2 = [uvw_poles_hex2 ; gtGetReflections(uvw_poles_hex(i,:), spacegroup)];
for ii = 1:size(uvw_poles_hex,1)
uvw_poles_hex2 = [uvw_poles_hex2 ; gtGetReflections(uvw_poles_hex(ii,:), spacegroup)];
end
uvw_poles_hex=uvw_poles_hex2;
......@@ -259,15 +259,15 @@ if app.plot_figure
% get the relevent uvw_poles
if strcmp(app.range, 'sst')
%for standard stereographic triangle
dum=find(uvw_poles(:,2)>=0 & uvw_poles(:,2)<=uvw_poles(:,1) & uvw_poles(:,3)>=uvw_poles(:,1));
dum=(uvw_poles(:,2)>=0 & uvw_poles(:,2)<=uvw_poles(:,1) & uvw_poles(:,3)>=uvw_poles(:,1));
uvw_poles=uvw_poles(dum, :);
elseif strcmp(app.range, 'phi90')
%for a 90 degree section of the pole figure
dum=find(uvw_poles(:,1)>=0 & uvw_poles(:,2)>=0 & uvw_poles(:,3)>=0);
dum=(uvw_poles(:,1)>=0 & uvw_poles(:,2)>=0 & uvw_poles(:,3)>=0);
uvw_poles=uvw_poles(dum, :);
elseif strcmp(app.range, 'phi360')
%for 360 pole figure - reduce only using psi
uvw_poles=uvw_poles(find(uvw_poles(:,3)>=0),:);
uvw_poles=uvw_poles(uvw_poles(:,3)>=0, :);
end
% plot these uvw/hkl poles
......@@ -298,10 +298,9 @@ if app.plot_figure
[ring_x,ring_y]=pol2cart(ring_phi,ring_r);
ring_z=ones(size(ring_phi))*(max(density(:))+1);
plot3(ring_x, ring_y, ring_z, 'w-');
if 0 % label rings
h=text(ring_x(1)+0.01, 0, (max(density(:))+1), num2str(ring));
set(h, 'color', 'w');
end
% label rings
%h=text(ring_x(1)+0.01, 0, (max(density(:))+1), num2str(ring));
%set(h, 'color', 'w');
end
end
......
function rmap=gtRvectorCmap
function rmap = gtRvectorCmap(phase_id)
% make a colormap from the r_vectors. Requires tha tthe r_vectors.mat
% variable has been created - use gtReadGrains
if ~exist('phase_id', 'var') || isempty(phase_id)
phase_id = 1;
end
if exist('r_vectors.mat', 'file')
load r_vectors
load r_vectors
else
disp('Loading most recent indexing output: index.mat');
indexFile = fullfile('4_grains', sprintf('phase_%02d', phase_id), ...
'index.mat');
try
disp('loading most recent indexing output: index.mat')
load 4_grains/phase_01/index
load(indexFile);
r_vectors=gtIndexAllGrainValues(grain, 'R_vector', '', 1:3, '');
r_vectors=[zeros(size(r_vectors, 1), 1) r_vectors];
catch
disp('neither r_vectors.mat nor index.mat was found :-(')
catch mexc
gtPrintException('neither r_vectors.mat nor index.mat was found :-(');
rmap=[]
return
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment