Why are only the cuboids near the surfaces visible?
- To: mathgroup at smc.vnet.net
- Subject: [mg132140] Why are only the cuboids near the surfaces visible?
- From: "Michael B. Heaney" <mheaney at alum.mit.edu>
- Date: Tue, 24 Dec 2013 02:18:09 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
Clear[psin, x, y, t, xi, yi, ti, kx, ky];
psin[x_, xi_, y_, yi_, t_, ti_, kx_,
ky_] := (20 E^(
1/2 I kx (-kx (t - ti) + 2 (x - xi)) +
1/2 I ky (-ky (t - ti) +
2 (y - yi)) - ((-kx (t - ti) + (x - xi))^2 + (-ky (t - ti) + (y -
yi))^2)/(1600 + 2 I (t - ti))) Sqrt[2/?])/(800 + I (t - ti));
f[x_, y_, t_] := psin[x, 0, y, 0, t, 0, 0.2, 0.2];
(* Mathematica normally assumes that all your variables are global.This means \
that every time you use a name like x, Mathematica normally assumes that you \
are referring to the same object. Particularly when you write \
programs,however,you may not want all your variables to be global.You may,for \
example,want to use the name x to refer to two quite different variables in \
two different programs. In this case,you need the x in each program to be \
treated as a local variable. You can set up local variables in Mathematica \
using modules. ithin each module,you can give a list of variables which are \
to be treated as local to the module.
Module[{x=Subscript[x, 0],?},expr]defines initial values for x, ?. *)
\
Module[
{func, opval, magMin, magMax, xmin = -100, xmax = 50, xstep = 5, ymin = -100,
ymax = 50, ystep = 5, tmin = 0, tmax = 100, tstep = 10},
magMin =
Minimize[{Abs[f[x, y, t]], xmin <= x <= xmax, ymin <= y <= ymax,
tmin <= t <= tmax}, {x, y, t}][[1]];
magMax =
Maximize[{Abs[f[x, y, t]], xmin <= x <= xmax, ymin <= y <= ymax,
tmin <= t <= tmax}, {x, y, t}][[1]];
(* Graphics3D[primitives,options] represents a threedimensional graphical \
image. Primitives can be Cuboid[...], directives can be Hue[h], Opacity[a], \
EdgeForm[spec], options can be Axes, AxesLabel, etc. *)
Graphics3D
[
(* Flatten only at level 1:
Flatten[{{a,b},{c,{d},e},{f,{g,h}}},1] gives {a,b,c,{d},e,f,{g,h}} *)
Flatten
[
(* Table[expr,{i,Subscript[i, min],Subscript[i, max]},{j,Subscript[j, min],
Subscript[j, max]},?]gives a nested list.
The list associated with i is outermost *)
Table
[
{
(* Hue[
h] is a graphics directive which specifies that objects which follow are \
to be displayed,if possible, in a color corresponding to hue h. Hue[h,s,b,
a] specifies colors in terms of hue,saturation, brightness, and opacity.
The parameters h,s,b, and a must all be between 0 and 1. Values of s,b,
and a outside this range are clipped.
Values of h outside this range are treated cyclically.
As h varies from 0 to 1, the color corresponding to Hue[
h] runs through red,yellow, green, cyan, blue, magenta,
and back to red again. *)
(* Arg[z] gives the argument ? in ?z?(e^(
i ?))
where the result is always between -? and +?. Modify this so the h-
value for Hue varies only between 0 and 1; *)
Hue[(Arg[func = f[x, y, t]] + ?)/2 ?],
If[Abs[func] < 0.001, opval = 0,
opval = 1 - ((magMax - Abs[func])/(magMax - magMin))];
(* Opacity[a] runs from a = 0 to 1,
with 0 representing perfect transparency. *)
Opacity[opval],
(* Edgeform[] draw no lines at the edges of the cuboid
*)
EdgeForm[],
(* Cuboid[{Subscript[x, min],Subscript[y, min],Subscript[z,
min]},{Subscript[x, max],Subscript[y, max],Subscript[z,
max]}]specifies a cuboid by giving the coordinates of opposite corners. *)
Cuboid
[{x, y, t}, {x + xstep, y + ystep, t + tstep}]
},
(* Table[expr,{i,Subscript[i, min],Subscript[i, max]},{j,Subscript[j,
min],Subscript[j, max]},?]gives a nested list.
The list associated with i is outermost *)
{x, xmin, xmax - xstep,
xstep}, {y, ymin, ymax - ystep, ystep}, {t, tmin, tmax - tstep, tstep}
],
(* Flatten only at level 1:
Flatten[{{a,b},{c,{d},e},{f,{g,h}}},1] gives {a,b,c,{d},e,f,{g,h}} *)
1
],
Axes -> True,
AxesLabel -> (Style[#, 18] & /@ {"x", "y", "t"})
]
]