[Date Index]
[Thread Index]
[Author Index]
Answer to "Points problem"
*To*: mathgroup at yoda.ncsa.uiuc.edu
*Subject*: Answer to "Points problem"
*From*: CAMERON at midd.cc.middlebury.edu
*Date*: Thu, 4 Oct 90 00:49 EDT
[[ Are members of MathGroup "MathGroupies" ? ]]
[[ Should I say "elements of the MathGroup" ? ]]
[[ Is it abelian? ]]
maxwebb at vitus.cse.ogi.edu (Max G. Webb) asks why some code like
Show[Graphics3D[ pointlist, shortlinelist ]];
displays the points in pointlist, but
Show[Graphics3D[ pointlist, longlinelist ]];
produces a display in which the points are missing.
He is falling afoul of a subtle feature of Mathematica
graphics: automatic scaling. Consider the function
boundingbox[x_] := Block[ {y=N[x]},
positions = Position[y,{_?NumberQ,_?NumberQ,_?NumberQ}];
coordinates = Apply[ (y[[##]])&, positions, {1} ];
{Min[#],Max[#]}& /@ Transpose[coordinates]
]
This function takes a Graphics3D object (or list of 3D graphics
primitives) and returns a list {{xmin,xmax},{ymin,ymax},{zmin,zmax}}
indicating the ranges of x, y, and z coordinates in the object.
The original posting's values for pointlist, shortlinelist,
and longlinelist are reproduced for reference at the end of
this note. With these values, we get
boundingbox[pointlist]
{{-1.367512718901739, 1.3608552544435},
{0.00111807892934969, 0.002607945574256309},
{0.001639740038943013, 0.003728634284214638}}
boundingbox[shortlinelist]
{{-0.1820927732, 0.}, {0., 0.0004133633611},
{0., 0.0008263234388}}
boundingbox[longlinelist]
{{-0.1854201093010261, 0.}, {0., 0.0005506040866933036},
{0., 0.001102215067405295}}
Note that the smallest y coordinate among the points is greater than
the largest y coordinate among the lines. Similarly for the z coordinates.
The x range for the points encloses the x range for the lines, but is
about fourteen times as big.
Whenever Mathematica displays Graphics or Graphics3D objects,
if PlotRange->Automatic is in effect (as it is by default if no
explicit PlotRange is given) then Mathematica goes through a complicated
(and, as far as I know, completely undocumented) sequence of calculations
to decide what range of values to display along each coordinate axis.
This computation includes, essentially, an analysis of the mean and
variance of the coordinates in the graphics list, with graphics features
whose coordinates are "outliers" being rejected. This is why, if you
ask Mathematica to do
Plot[ Tan[x], {x,0,2Pi} ]
you get a reasonable plot, chopped off at reasonable y-coordinates.
The points "near" +/- infinity are chopped off because they are too far
from the mean y-coordinate (most points on that graph have y-coordinates
near 0; only points with x-coordinates very near Pi/2 or 3Pi/2 have
y-coordinates far from 0).
Although I don't know the details of how Mathematica decides what to keep
and what to reject, this example suggests that it gives more weight to
Line objects than to Point objects, because adding a couple of Line's
to the graphic radically changes the default scale. At any rate,
if you do the following:
Show[Graphics3D[{pointlist,shortlinelist}],
PlotRange->{{-1.4,1.4},{0.,.003},{0.,.004}},
BoxRatios->{1,1,1}
];
and
Show[Graphics3D[{pointlist,longlinelist}],
PlotRange->{{-1.4,1.4},{0.,.003},{0.,.004}},
BoxRatios->{1,1,1}
];
then you override the automatic scaling, and you will get pictures that
I believe are much closer to what the original poster wanted and expected
to get.
--Cameron Smith
Mathematica programming consultant
CAMERON at MIDD.BITNET --or-- cameron at midd.cc.middlebury.edu
The original posting had
pointlist =
{PointSize[0.05], GrayLevel[0.5],
Point[{-1.367511195263215,
0.001195340754223037,
0.003139555787092553}],
Point[{-1.367512718901739,
0.001195342899414338,
0.001639740038943013}],
Point[{1.36085379675106,
0.002607945574256309,
0.00372862923999308}],
Point[{1.3608552544435,
0.00111807892934969,
0.003728634284214638}]
};
and
shortlinelist =
{
Line[{{0., 0., 0.},
{-0.003327336062,
0.0004133633611,
0.0008263234388}}],
Line[{{-0.003327336062, 0.0004133633611, 0.0008263234388},
{-0.1820927732, 0.0001372407256, 0.0002758916286}}]
};
and
longlinelist =
{
Line[{{0., 0., 0.},
{-0.003327336062,
0.0004133633611,
0.0008263234388}}],
Line[{{-0.003327336062, 0.0004133633611, 0.0008263234388},
{-0.1820927732, 0.0001372407256, 0.0002758916286}}],
Line[{{-0.1854201093010261,
0.0005506040866933036,
0.001102215067405295},
{0., 0., 0.}}],
Line[{{-0.1854201093010261,
0.0005506040866933036,
0.001102215067405295},
{-0.1820927751, 0.0001345637681, 0.0002715492562}}]
};
Prev by Date:
**bugs with N ...**
Next by Date:
**long comments**
Previous by thread:
**bugs with N ...**
Next by thread:
**long comments**
| |