Re: 3D-plot over a triangle

• To: mathgroup at smc.vnet.net
• Subject: [mg65160] Re: 3D-plot over a triangle
• From: Oliver Ruebenkoenig <ruebenko at uni-freiburg.de>
• Date: Wed, 15 Mar 2006 23:59:35 -0500 (EST)
• Organization: InterNetNews at News.BelWue.DE (Stuttgart, Germany)
• References: <duudid\$i2k\$1@smc.vnet.net><dv694g\$o51\$1@smc.vnet.net> <dv8vu8\$nh7\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Wed, 15 Mar 2006, carlos at colorado.edu wrote:

You might want to try:

http://www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb/imsTOC/Differential%20Equation%20Systems/Utilities/ShapeFunctionsDocu.html

Oliver

> Here is the code of the plot-function-over-trig module in case
> somebody wants to try it.  It is *very* slow but to
> produce a few plots for a paper or report that is not
> a major concern - clean looks are more important.
>
> PlotTriangleShapeFunction[xytrig_,f_,Nsub_,aspect_]:=Module[
>  {Ni,line3D={},poly3D={},zc1,zc2,zc3,xyf1,xyf2,xyf3,
>   xc,yc, x1,x2,x3,y1,y2,y3,z1,z2,z3,iz1,iz2,iz3,d},
>  {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}}=Take[xytrig,3];
>   xc={x1,x2,x3}; yc={y1,y2,y3}; Ni=Nsub*3;
>   For[iz1=1,iz1<=Ni,iz1++, For [iz2=1,iz2<=Ni-iz1,iz2++,
>       iz3=Ni-iz1-iz2; If [iz3<=0, Continue[]]; d=0;
>       If [Mod[iz1+2,3]==0&&Mod[iz2-1,3]==0, d=  1];
>       If [Mod[iz1-2,3]==0&&Mod[iz2+1,3]==0, d=-1];
>       If [d==0, Continue[]];
>       zc1=N[{iz1+d+d,iz2-d,iz3-d}/Ni];
>       zc2=N[{iz1-d,iz2+d+d,iz3-d}/Ni];
>       zc3=N[{iz1-d,iz2-d,iz3+d+d}/Ni];
>       xyf1={xc.zc1,yc.zc1,f[zc1[[1]],zc1[[2]],zc1[[3]]]};
>       xyf2={xc.zc2,yc.zc2,f[zc2[[1]],zc2[[2]],zc2[[3]]]};
>       xyf3={xc.zc3,yc.zc3,f[zc3[[1]],zc3[[2]],zc3[[3]]]};
>       AppendTo[poly3D,Polygon[{xyf1,xyf2,xyf3}]];
>       AppendTo[line3D,Line[{xyf1,xyf2,xyf3,xyf1}]]
>    	]];
>   Show[Graphics3D[RGBColor[1,0,0]],Graphics3D[poly3D],
> 	   Graphics3D[Thickness[.002]],Graphics3D[line3D],
> 	   Graphics3D[RGBColor[0,0,0]],Graphics3D[Thickness[.005]],
> 	   Graphics3D[Line[xytrig]],PlotRange->All,
> 	   BoxRatios->{1,1,aspect},Boxed->False]
> 	];
>
> (* test statements *)
> xyc1={0,0,0}; xyc2={3,0,0}; xyc3={Sqrt[3],3/2,0};
> xytrig=N[{xyc1,xyc2,xyc3,xyc1}]; Nsub=16;
>
> N1[zeta1_,zeta2_,zeta3_]:=(9/2)*zeta1*(zeta1-1/3)*(zeta1-2/3);
> N2[zeta1_,zeta2_,zeta3_]:=(9/2)*zeta2*(zeta2-1/3)*(zeta2-2/3);
> N3[zeta1_,zeta2_,zeta3_]:=(9/2)*zeta3*(zeta3-1/3)*(zeta3-2/3);
> N4[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta1*zeta2*(zeta1-1/3);
> N5[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta2*zeta1*(zeta2-1/3);
> N6[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta2*zeta3*(zeta2-1/3);
> N7[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta3*zeta2*(zeta3-1/3);
> N8[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta3*zeta1*(zeta3-1/3);
> N9[zeta1_,zeta2_,zeta3_]:=(27/2)*zeta1*zeta3*(zeta1-1/3);
> N10[zeta1_,zeta2_,zeta3_]:=27*zeta1*zeta2*zeta3;
> PlotTriangleShapeFunction[xytrig,N1,Nsub,1/2];
> PlotTriangleShapeFunction[xytrig,N2,Nsub,1/2];
> PlotTriangleShapeFunction[xytrig,N3,Nsub,1/2];
> PlotTriangleShapeFunction[xytrig,N4,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N5,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N6,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N7,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N8,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N9,Nsub,1/3];
> PlotTriangleShapeFunction[xytrig,N10,Nsub,1/4];
>
>

Oliver Ruebenkoenig, <ruebenko at imtek.de>
Phone: ++49 +761 203 7388

```

• Prev by Date: Re: FileDate, or rather Microsoft
• Next by Date: Re: Finding a shorter form for coplanar point in 3D space
• Previous by thread: Re: 3D-plot over a triangle