From 515b3980bac5c202ac95096a5ddb9f2d211966f0 Mon Sep 17 00:00:00 2001 From: treecity Date: Sat, 21 May 2011 10:40:51 +0000 Subject: [PATCH] =?utf8?q?[src]=20unter=20para=20Bedinungen=20werden=20imm?= =?utf8?q?er=20die=20richtigen=20Werte=20generiert=20[src]=20weitere=20Anp?= =?utf8?q?assungen=20auf=204=20Punkte=20pro=20Element=20[src]=20PlotShape?= =?utf8?q?=20zeichnet=20nun=20auch=20die=20erste=20Koordinate=20ein=20(?= =?utf8?q?=C3=9Cbergangsstest)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://drops.fb12.tu-berlin.de/svn/bacc/trunk@30 26120e32-c555-405d-b3e1-1f783fb42516 --- src/Aelements.m | 2 +- src/build_A.cpp | 61 +++++++++++++++++++++++++---------------- src/exmpl_2DLShape.mat | Bin 254 -> 555 bytes src/plotShape.m | 14 +++++----- src/quad_norm.m | 4 +-- src/test_solveError.m | 3 +- 6 files changed, 49 insertions(+), 35 deletions(-) diff --git a/src/Aelements.m b/src/Aelements.m index 2526bdf..aad35f5 100644 --- a/src/Aelements.m +++ b/src/Aelements.m @@ -10,7 +10,7 @@ A=0; for i = 1:elles tri = elements(i,:); a = (coordinates(tri(1),:)-coordinates(tri(2),:)); - b = (coordinates(tri(1),:)-coordinates(tri(3),:)); + b = (coordinates(tri(1),:)-coordinates(tri(4),:)); A1 = norm(cross(a',b')); A = A+ A1; end diff --git a/src/build_A.cpp b/src/build_A.cpp index d880ef5..49175fd 100644 --- a/src/build_A.cpp +++ b/src/build_A.cpp @@ -20,7 +20,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { //sicherheitsabfragen zu Datengroessen if (nrhs != 2) - mexErrMsgTxt("expected (coordinates(Nx3),elements(Mx3))"); + mexErrMsgTxt("expected (coordinates(Nx3),elements(Mx4))"); if (nlhs > 1) mexErrMsgTxt("has only one output argument"); @@ -31,8 +31,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexErrMsgTxt("expected coordinates (Nx3)"); int em = mxGetM(prhs[1]); int en = mxGetN(prhs[1]); - if (en != 3) - mexErrMsgTxt("expected elements (Mx3)"); + if (en != 4) + mexErrMsgTxt("expected elements (Mx4)"); //Vorbereitung der Daten plhs[0] = mxCreateDoubleMatrix(em, em, mxREAL); @@ -42,6 +42,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double * x0 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * x1 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); + double * x2 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * x3 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * xn = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * xa = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); @@ -49,6 +50,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double * y0 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * y1 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); + double * y2 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * y3 = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * yn = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); double * ya = mxGetPr(mxCreateDoubleMatrix(3, 1, mxREAL)); @@ -72,9 +74,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { x1[1] = C[cm + (int) E[em + j] - 1]; x1[2] = C[2 * cm + (int) E[em + j] - 1]; - x3[0] = C[(int) E[2 * em + j] - 1]; - x3[1] = C[cm + (int) E[2 * em + j] - 1]; - x3[2] = C[2 * cm + (int) E[2 * em + j] - 1]; + x2[0] = C[(int) E[2 * em + j] - 1]; + x2[1] = C[cm + (int) E[2 * em + j] - 1]; + x2[2] = C[2 * cm + (int) E[2 * em + j] - 1]; + + x3[0] = C[(int) E[3 * em + j] - 1]; + x3[1] = C[cm + (int) E[3 * em + j] - 1]; + x3[2] = C[2 * cm + (int) E[3 * em + j] - 1]; for (i = 0; i<3;++i) xa[i] = x1[i] - x0[i]; @@ -119,20 +125,21 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { dt[i] = - x0[i]; }else{ for (i = 0; i<3;++i) - dt[i] = - x1[i]; + dt[i] = - x3[i]; } }else{ if(xb[rxb]>0){ for (i = 0; i<3;++i) - dt[i] = - x3[i]; + dt[i] = - x1[i]; }else{ - //for (i = 0; i<3;++i) - // d[i] = - x2[i]; - printf("Error! Daten existieren nicht. Zugriff auf vierten punkt"); + for (i = 0; i<3;++i) + dt[i] = - x2[i]; + //printf("Error! Daten existieren nicht. Zugriff auf vierten punkt"); } } - + //for (i=0;i<3;++i) + // dt[i] = 0; // printf("(%d n- %f | %f | %f)\n",j,xn[0],xn[1],xn[2]); @@ -146,9 +153,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { y1[1] = C[cm + (int) E[em + k] - 1]; y1[2] = C[2 * cm + (int) E[em + k] - 1]; - y3[0] = C[(int) E[2 * em + k] - 1]; - y3[1] = C[cm + (int) E[2 * em + k] - 1]; - y3[2] = C[2 * cm + (int) E[2 * em + k] - 1]; + y2[0] = C[(int) E[2 * em + k] - 1]; + y2[1] = C[cm + (int) E[2 * em + k] - 1]; + y2[2] = C[2 * cm + (int) E[2 * em + k] - 1]; + + y3[0] = C[(int) E[3 * em + k] - 1]; + y3[1] = C[cm + (int) E[3 * em + k] - 1]; + y3[2] = C[2 * cm + (int) E[3 * em + k] - 1]; for (i = 0; i<3;++i) ya[i] = y1[i] - y0[i]; @@ -189,30 +200,32 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { d[i] = dt[i] + y0[i]; }else{ for (i = 0; i<3;++i) - d[i] = dt[i] + y1[i]; + d[i] = dt[i] + y3[i]; } }else{ if(yb[ryb]>0){ for (i = 0; i<3;++i) - d[i] = dt[i] + y3[i]; + d[i] = dt[i] + y1[i]; }else{ - //for (i = 0; i<3;++i) - //d[i] += y2[i]; - printf("Error! Daten existieren nicht. Zugriff auf vierten punkt"); + for (i = 0; i<3;++i) + d[i] = dt[i] + y2[i]; + //printf("Error! Daten existieren nicht. Zugriff auf vierten punkt"); } } - for (i = 0; i<3;++i) - d[i] = y0[i]-x0[i]; + // for (i = 0; i<3;++i) + // d[i] = y0[i]-x0[i]; printf("(%d,%d)",rx,ry); if (rx == ry) { printf("(%d,%d@%d,%d)",rxa,rxb,rya,ryb); - printf("[%.2f,%.2f@%.2f,%.2f]\n",xa[rxa],xb[rxb],ya[rya],yb[ryb]); + printf("[%.2f,%.2f@%.2f,%.2f]",xa[rxa],xb[rxb],ya[rya],yb[ryb]); + printf("%d%d %.1f %.1f %.1f|||",j,k,dt[0],dt[1],dt[2]); + printf("%d%d %.1f %.1f %.1f\n",j,k,d[0],d[1],d[2]); if (rxa == rya) { //printf("%d%d %.1f %.1f | %.1f %.1f || %.1f %.1f | %.1f %.1f || %.1f %.1f %.1f\n",j,k,x0[0], x1[0], x0[1], x3[1], y0[0], // y1[0], y0[1], y3[1], d[0], d[1], d[2]); - printf("%d%d %.1f %.1f %.1f\n",j,k,d[0],d[1],d[2]); + //printf("%d%d %.1f %.1f %.1f\n",j,k,d[0],d[1],d[2]); tmp = quad0Int(F_par, fabs(xa[rxa]), fabs(xb[rxb]), fabs(ya[rxa]), fabs(yb[rxb]), d[rxa], d[rxb], d[rx]); // printf("%d%d|%.2f\n",j,k,tmp); diff --git a/src/exmpl_2DLShape.mat b/src/exmpl_2DLShape.mat index cf8287e1d2af1ed1fc5d1809ce87680864a04417..feb1a9435624f9e922a173ddea746e683980b0e6 100644 GIT binary patch literal 555 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NSER4_EMGBC3;F;y@!Ff>#k5il@%`tma{FsK4?#hk~<2?+)aNoESq z8ZIdu;CgC&$k5n1DbA2tc*fBK3=9e`jO##(?cs_$kQ6r?7z-FP8JY{IKYuR1H07D< zv?XHAR}C3AvM@(53QI6b_W1Pp1SCr^{8L~}0vTfoH|7J9F~-b>+ycfV^to+-LUl%ZXnMGa(t7ufz|KuivOHcr-1*&PR@+)T;?hOBwg> p=H3o6KpSr124pWBG8A@p)naB=54rPjgVT%Ge3tAC7E4){006CRu(1FD delta 162 zcmZ3@@{e(Xsd#Cgf@49Ef}w$ep{bRrp_Q?*f{}rt;lx1gi3zL|YdET`85kHU<~&YL zNa$clGE;cga7p1n*O7F#BsYa;Y>%G&`Lk%snLS4)T}j$trKTX3#Gsv!#1h=&!{fog z@Mk@12tQD}G2Dm`a3i>$8ao>*Pnkb!@~qjj!h_DRq!c$DnK@%-M8wR<#9s_;7A$-K DO!_?E diff --git a/src/plotShape.m b/src/plotShape.m index 8aedde4..8016864 100644 --- a/src/plotShape.m +++ b/src/plotShape.m @@ -39,19 +39,19 @@ if(c) hold on end -%% Dreiecke einzeichnen +%% Flächen eles = size(elements,1); if(e) for idx = 1:eles - current = coordinates(elements(idx,[1:3,3,1])',:); - current(3,:) = current(3,:)-current(1,:)+current(2,:); + current = coordinates(elements(idx,[1:4,1])',:); +% current(3,:) = current(3,:)-current(1,:)+current(2,:); fill3(current(:,1),current(:,2),current(:,3),'b'); % Zeichnet Oberflaeche hold on end else for idx = 1:eles - current = coordinates(elements(idx,[1:3,3,1])',:); - current(3,:) = current(3,:)-current(1,:)+current(2,:); + current = coordinates(elements(idx,[1:4,1])',:); +% current(3,:) = current(3,:)-current(1,:)+current(2,:); plot3(current(:,1),current(:,2),current(:,3),'b'); % Zeichnet nur Kanten hold on end @@ -64,8 +64,8 @@ if(n) anorm = quad_norm(coordinates,elements); end for idx = 1:eles - current = sum(coordinates(elements(idx,[2,3])',:),1)/2; - current = [current ; current+anorm(idx,:)]; + current = sum(coordinates(elements(idx,[2,4])',:),1)/2; + current = [current ; current+anorm(idx,:);coordinates(elements(idx,1)',:)]; plot3(current(:,1),current(:,2),current(:,3),'r'); % Zeichnet Oberflaeche scatter3(current(2,1),current(2,2),current(2,3),'xr'); hold on diff --git a/src/quad_norm.m b/src/quad_norm.m index 6dbfe79..2bd8cb8 100644 --- a/src/quad_norm.m +++ b/src/quad_norm.m @@ -25,12 +25,12 @@ end %% calculate the Norm - n = zeros(size(elements)); + n = zeros(size(elements,1),3); for i = 1:s_ele % normalized Vector on every triangle tri = elements(i,:); a = (coordinates(tri(2),:)-coordinates(tri(1),:)); - b = (coordinates(tri(3),:)-coordinates(tri(1),:)); + b = (coordinates(tri(4),:)-coordinates(tri(1),:)); N = cross(a',b'); if(w) N = N/norm(N); diff --git a/src/test_solveError.m b/src/test_solveError.m index 5f2c47a..4eca864 100644 --- a/src/test_solveError.m +++ b/src/test_solveError.m @@ -3,7 +3,8 @@ load exmpl_2DLShape % coordinates = coordinates(:,[ 1 3 2]); -% elements(2,:) = elements(2,[ 2 3 1]); +elements(2,:) = elements(2,[ 3 4 1 2]); +elements(3,:) = elements(3,[ 3 2 1 4]); % [coordinates,elements]=refineQuad(coordinates,elements,ones(1,size(elements,1))); % [coordinates,elements]=refineQuad(coordinates,elements,ones(1,size(elements,1))); -- 2.47.3