1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
function mapping6
global long lat alpha beta eta xi zeta D
[alpha1, alpha2, beta1, beta2]=function3;
%# pixels units
screensize = get( groot, 'Screensize' );
xSize = screensize(3)/2;
ySize = screensize(4);
FigHandle6 = figure('Name','Conical pattern 3','NumberTitle','off');
set(FigHandle6, 'units','pixels', 'Position',[0 0 xSize ySize]);
alpha1 =36; beta1 = 12;
lat = 10;
eta = 10;xi = 10;
D = 2;
long = lat*sind(alpha)/sind(beta);
% Points and angles (angle in radians)
zeta = 0;
m=0;n=0;
u=0;v=0;t=0;k=0;
rot=0; xmax=0; ymax=0;
xA = m;
yA = n;
xB = m+lat;
yB = n;
xD = m+long*cosd(alpha1+beta1);
yD = n+long*sind(alpha1+beta1);
aAC = tand(alpha1);
bAC = yA - aAC*xA;
S = roots([aAC^2+1 -2*yB*aAC-2*xB bAC^2+yB^2+xB^2-2*yB*bAC-long^2]);
xC1 = m+max(S);
yC1 = n+aAC*xC1+bAC;
diag = sqrt((yC1-yA)^2+(xC1-xA)^2);
aDC = (yC1-yD)/(xC1-xD);
alpha2 = alpha1 -atand(aDC) ;
beta2 = acosd((lat^2-long^2-diag^2)/(-2*long*diag));
% Sample data
for i=1:1:eta
for j=1:1:xi
x = [m+xA m+lat m+diag*cosd(alpha1) m+long*cosd(alpha1+beta1) m+xA];
y = [n+yA n+yB n+diag*sind(alpha1) n+long*sind(alpha1+beta1) n+yA];
diagx = [m+xA m+diag*cosd(alpha1)];
diagy = [n+yA n+diag*sind(alpha1)];
m = x(1);
n = y(1);
% Tx matrices
first = [m n;m n;m n;m n;m n];
third = [m n;m n];
if j == 1
if i==1
second = [cosd(zeta) -sind(zeta);sind(zeta) cosd(zeta)];
else if aDE<0
second = [cosd(zeta+180) -sind(zeta+180);sind(zeta+180) cosd(zeta+180)];
else
second = [cosd(zeta+180*k) -sind(zeta+180*k);sind(zeta+180*k) cosd(zeta+180*k)];
end
end
else
if i==1
second = [cosd(zeta+rot) -sind(zeta+rot);sind(zeta+rot) cosd(zeta+rot)];
else if aDE<0 && t>1
second = [cosd(zeta+rot+180) -sind(zeta+rot+180);sind(zeta+rot+180) cosd(zeta+rot+180)];
else
second = [cosd(zeta+rot+180*k) -sind(zeta+rot+180*k);sind(zeta+rot+180*k) cosd(zeta+rot+180*k)];
end
end
end
% Use homogenous coords
mp_quad(:,1) = x';
mp_quad(:,2) = y';
mp_diag(:,1) = diagx';
mp_diag(:,2) = diagy';
% Calculate (note because we premultiply)
rotated_quad = (second* (mp_quad-first)')+first';
rotated_diag = (second* (mp_diag-third)')+third';
plot(rotated_quad(1,:), rotated_quad(2,:),'color',[1 1 0],'linewidth',2)
hold on
axis equal
grid off
axis off
plot(rotated_diag(1,:), rotated_diag(2,:),'--','color','r')
title('Transformed crease pattern of conical structure','color','y','FontSize',25,'Fontname','Helvetica','Fontweight','bold')
delta = beta2-beta1;
zeta = j*delta;
if j == 1 && i == 1
aAB = (y(2)-y(1))/(x(2)-x(1));
end
if j == 1
aDE = (rotated_quad(2,3)-rotated_quad(2,4))/(rotated_quad(1,3)-rotated_quad(1,4));
u=rotated_quad(1,4);
v=rotated_quad(2,4);
if aDE<0
t=t+1;
else if t>1
t=0;
k=1;
end
end
end
m=rotated_quad(1,2);
n=rotated_quad(2,2);
%Cerlce bottom
if i == 1 && j == xi
xF1 = rotated_quad(1,2);
yF1 = rotated_quad(2,2);
end
if i == D+1 && j == 1
xE1 = rotated_quad(1,1);
yE1 = rotated_quad(2,1);
end
if i == D && j == floor((xi+1)/2)
if xi/2 == round(xi/2)
xM1 = rotated_quad(1,2);
yM1 = rotated_quad(2,2);
else
xM1 = (rotated_quad(1,1)+rotated_quad(1,2))/2;
yM1 = (rotated_quad(2,1)+rotated_quad(2,2))/2;
end
end
%Cerlce top
if i == eta-D+1 && j == xi
xF2 = rotated_quad(1,2);
yF2 = rotated_quad(2,2);
end
if i == eta && j == 1
xE2 = rotated_quad(1,4);
yE2 = rotated_quad(2,4);
end
if i == eta && j == floor((xi+1)/2)
if xi/2 == round(xi/2)
xM2 = rotated_quad(1,2);
yM2 = rotated_quad(2,2);
else
xM2 = (rotated_quad(1,1)+rotated_quad(1,2))/2;
yM2 = (rotated_quad(2,1)+rotated_quad(2,2))/2;
end
end
end
m = u;
n = v;
if rotated_quad(1,2)>xmax
xmax = rotated_quad(1,2);
end
if rotated_quad(1,2)>ymax
ymax = rotated_quad(2,2);
end
AB = sqrt((rotated_quad(2,1)-rotated_quad(2,2))^2+(rotated_quad(1,1)-rotated_quad(1,2))^2);
CD = sqrt((rotated_quad(2,3)-rotated_quad(2,4))^2+(rotated_quad(1,3)-rotated_quad(1,4))^2);
scale = CD/AB;
long = long*scale;
rot=atand((aDE-aAB)/(1+aDE*aAB));
zeta = rot;
lat=sqrt((mp_quad(4,1)-mp_quad(3,1))^2+(mp_quad(4,2)-mp_quad(3,2))^2);
diag = sqrt(lat^2+long^2-2*lat*long*cosd(180-alpha1-beta2));
end
xIE = (xE1+xM1)/2;
yIE = (yE1+yM1)/2;
aEM = (yM1-yE1)/(xM1-xE1);
aEMp = -1/aEM;
bEMp = yIE-aEMp*xIE;
xIF = (xF1+xM1)/2;
yIF = (yF1+yM1)/2;
aMF = (yF1-yM1)/(xF1-xM1);
aMFp = -1/aMF;
bMFp = yIF-aMFp*xIF;
xC1 = (bMFp-bEMp)/(aEMp-aMFp);
yC1 = aMFp*xC1+bMFp;
xIE = (xE2+xM2)/2;
yIE = (yE2+yM2)/2;
aEM = (yM2-yE2)/(xM2-xE2);
aEMp = -1/aEM;
bEMp = yIE-aEMp*xIE;
xIF = (xF2+xM2)/2;
yIF = (yF2+yM2)/2;
aMF = (yF2-yM2)/(xF2-xM2);
aMFp = -1/aMF;
bMFp = yIF-aMFp*xIF;
xC2 = (bMFp-bEMp)/(aEMp-aMFp);
yC2 = aMFp*xC2+bMFp;
R0 = sqrt((yC1-yA)^2+(xC1-xA)^2);
R1 = sqrt((yC1-yE1)^2+(xC1-xE1)^2);
R2 = sqrt((yC2-yE2)^2+(xC2-xE2)^2);
aC1E = (yC1-yE1)/(xC1-xE1);
aC1F = (yC1-yF1)/(xC1-xF1);
aC2E = (yC2-yE2)/(xC2-xE2);
aC2F = (yC2-yF2)/(xC2-xF2);
phi1 = atand((-aC1E+aC1F)/(1+aC1E*aC1F));
phi2 = atand((-aC2E+aC2F)/(1+aC2E*aC2F));
%Cercle bottom
d = sqrt((xF1-xE1)^2+(yF1-yE1)^2); % Distance between points
a = atan2(-(xF1-xE1),yF1-yE1); % Perpendicular bisector angle
b = asin(d/2/R1); % Half arc angle
c = linspace(a-b,a+b); % Arc angle range
e = sqrt(R1^2-d^2/4); % Distance, center to midpoint
x = (xE1+xF1)/2-e*cos(a)+R1*cos(c); % Cartesian coords. of arc
y = (yE1+yF1)/2-e*sin(a)+R1*sin(c);
t=linspace(0,2*pi,1000);
ux=R0*cos(t)+xC1;
uy=R0*sin(t)+yC1;
vx=R1*cos(t)+xC1;
vy=R1*sin(t)+yC1;
X=[ux(1:end-1);ux(2:end);vx(2:end);vx(1:end-1)];
Y=[uy(1:end-1);uy(2:end);vy(2:end);vy(1:end-1)];
plot(x,y,'color',[1 1 0],'linewidth',2);
%Cercle top
d = sqrt((xF2-xE2)^2+(yF2-yE2)^2); % Distance between points
a = atan2(-(xF2-xE2),yF2-yE2); % Perpendicular bisector angle
b = asin(d/2/R2); % Half arc angle
c = linspace(a-b,a+b); % Arc angle range
e = sqrt(R2^2-d^2/4); % Distance, center to midpoint
x = (xE2+xF2)/2-e*cos(a)+R2*cos(c); % Cartesian coords. of arc
y = (yE2+yF2)/2-e*sin(a)+R2*sin(c);
THETA=linspace(0,2*pi,1000);
RHO=ones(1,1000)*R2;
[X,Y] = pol2cart(THETA,RHO);
X=X+xC2;
Y=Y+yC2;
plot(x,y,'color',[1 1 0],'linewidth',2);
zoom on
%# figure size printed on paper
set(FigHandle6, 'PaperUnits','centimeters')
set(FigHandle6, 'PaperSize',[XA3 YA3])
set(FigHandle6, 'PaperPosition',[xMargin yMargin xSize ySize])
set(FigHandle6, 'PaperOrientation','portrait')
axis([xE1 xmax 0 yC1])
% %# export to PDF and open file
% print -dpdf -r0 Mapping6.pdf
% winopen Mapping6.pdf |
Partager