       Re: 3D Plot of frequency data

• To: mathgroup at smc.vnet.net
• Subject: [mg62723] Re: 3D Plot of frequency data
• From: dh <dh at metrohm.ch>
• Date: Fri, 2 Dec 2005 05:53:35 -0500 (EST)
• References: <dmjrcm\$5ud\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Leigh,
a linear transformation that transforms
v1 = {0, 0, 0};
v2 = {1, 0, 0};
v3 = {0, 1, 0};
v4 = {0, 0, 1};
into a regular tetrahedron centered at {0,0,0}:
w1 = {0, 0, Sqrt[2/3]};
w2 = {1/2, -1/Sqrt, 0};
w3 = {-1/2, -1/Sqrt, 0};
w4 = {0, 1/Sqrt, 0};

is:

lintrans[v_]:=Module[{
mat={{1/2, -1/2, 0}, {-1/(2*Sqrt),
-1/(2*Sqrt), 1/Sqrt},
{-Sqrt[2/3], -Sqrt[2/3], -Sqrt[2/3]}},
tr={0, 0, Sqrt[2/3]}
},
mat.v+tr
]

Concerning the surface, the implicite equation can be made explicite by
solving for x3 (for x1 and x2 !=0):
x3= (x1 - x1^2 - x1*x2)/(x1 + x2)

the parametrized (by x1,x2) surface in old coordinates are(note that
x1=x2= 0 is excluded):
{x1, x2, (x1 - x1^2 - x1*x2)/(x1 + x2)}
and in new coordinates:
lintrans[ {x1, x2, (x1 - x1^2 - x1*x2)/(x1 + x2)} ]
we can plot this by:

g1=ParametricPlot3D[lintrans[ {x1, x2, (x1 - x1^2 - x1*x2)/(x1 + x2)}
],{x1, 0.001, 1}, {x2, 0.001, 1}]

To display the tetrahedron by a wire frame, we change the definition of
"thedrahedron":
tetrahedron[{v1_, v2_, v3_, v4_}] := {Line[{v1, v2, v3, v1}], Line[{v1,
v2, v4, v1}], Line[{v1, v4, v3, v1}], Line[{v4, v2, v3, v1}]};
the tetraedron canthen be plotted by:
g2 = Graphics3D[{Thickness[0.01],
tetrahedron[lintrans /@ {{0, 0, 0}, {1, 0,
0} , {0, 1, 0}, {0, 0, 1}}]
}];

and we may combine the plots by:
Show[g1, g2, PlotRange -> {0, 1}]

have fun, Daniel

leigh pascoe wrote:
> Dear Mathgroup,
>
> I would like to do a 3D plot of several functions where the coordinates
> (x, y,z) are subject to the restrictions
>
> x>=0
> y>=0
> z>=0
> x+y+z<=1
>
> These restrictions arise naturally when considering the frequencies of
> four types in a population. The fourth frequency, subject to similar
> restrictions, is just 1-x-y-z.
>
> I believe this range of possible values defines a tetrahedron with
> vertices (0,0,0),(1,0,0), (0,1,0),(0,0,1) that could be drawn using the
> code recently posted by David Park. i.e.
>
> v1 = {0, 0, 0};
> v2 = {1, 0, 0};
> v3 = {0, 1, 0};
> v4 = {0, 0, 1};
>
> tetrahedron[{v1_, v2_, v3_, v4_}] := {Polygon[{v1, v2, v3}], Polygon[{v1, v2, v4}], Polygon[{v1, v4, v3}], Polygon[{v4, v2, v3}]};
>
> Show[Graphics3D[tetrahedron[{v1, v2, v3, v4}]]];
>
> If possible (for symmetry) I would like to apply a shear function (say
> to the y and z directions) so that the resulting tetrahedron would be
> regular. A point (x1,x2,x3) could then be plotted by measuring along
> each of the sides of the tetrahedron corresponding to the original axes
> and finding the intersection point of the perpendiculars. I imagine a
> transformation can be defined to convert the (x1,x2,x3) or (x',y',z')
> coordinates to the orthogonal (x,y,z) system if this is necessary.
>
> Now to the functions. As  first step I would like to plot within this
> regular tetrahedron the implicit function
>
> x2 x3-x1(1-x1-x2-x3)=0
>
> This is a twisted surface that would have edges corresponding to the axes
> x'=y'=0 (z' axis) and
> x'=z'=0 (y' axis)
> and the tetrahedral sides defined by
> 1-x'-y'-z'=0=y' and
> 1-x'-y'-z'=0=z'
>
> For easy visualisation the tetrahedron should be a wireframe and the
> function surface should be shown as a grid mesh. I would then like to
> add some individual points, both on  and off the surface and ultimately
> some trajectories (lines) defined by a series of points. The ability to
> visualise points and functions in this manner would be very useful when
> considering problems related to frequency data. Can anyone help me to do
> this in Mathematica?
>
> Thanks
>
> Leigh
>
>
>
>

```

• Prev by Date: Re: Problem with RSolve
• Next by Date: Types in Mathematica thread
• Previous by thread: Re: Programmatic Search and Replace