Message Boards Message Boards

1
|
5158 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Use BoxRatios, vp, vc to replace plot box for Graphics3D ?

Anonymous User
Anonymous User
Posted 7 years ago

I add Boxed->False and wished to provide my own 3D plot box. How am I to proceede?

I'm having trouble understanding AbsoluteOptions for a graphic (see below).

I need to use PlotRange, BoxRatios, and ViewCenter in a sensible manner (reason why omitted). But for this graphic the results Mathematica shows me (using AbsoluteOptions) seem impossible to use. Question: how can it be that PlotRange is width of .3 if Arrows are width 2? Even if I construe I must apply Boxratios first, I'm clipped by .3.

Question two: look at ViewCenter - it isn't in the PlotRange, how can viewcenter not be in the plot?

We are not given ViewVector but I assume it's along the default direction {1.3,-2.4,2.} at a sufficient distance to show the graphic. However that is not sufficent because though we know the shape of the box by boxratios: I cant figure the size unless I know the dimensions of every graphic plotted (which depends on viewing distance).

How am I to procede in a "generic manner" to put my own plot box around Graphic3D (obviously I would then include the fresh box in the Graphic3D as a list of things to render) ?

note CAREFULLY that the AbsoluteOptions when Text[...,{0,0,0}] are digest-able. It's when Text is not at origin that I see Options that I do not understand the proper use of. thank you.

xx = Text["XXX\nXXX\nXXX", {0, 0, .2}, {0, 0}];

Graphics3D[{xx, Sphere[{0, 0, 0}, .15], RGBColor[.7, 0, 0], 
  Arrow[{{0, 0, 0}, {2, 0, 0}}, .1], RGBColor[0, .5, 0], 
  Arrow[{{0, 0, 0}, {0, 2, 0}}, .1], RGBColor[0, 0, .5], 
  Arrow[{{0, 0, 0}, {0, 0, 2}}, .1]}]

In[1168]:= AbsoluteOptions[%]

Out[1168]= {AlignmentPoint -> Center, AspectRatio -> Automatic, 
 AutomaticImageSize -> False, Axes -> False, AxesEdge -> Automatic, 
 AxesLabel -> None, AxesOrigin -> Automatic, AxesStyle -> {}, 
 Background -> None, BaselinePosition -> Automatic, BaseStyle -> {}, 
 Boxed -> True, BoxRatios -> {0.857143, 0.857143, 1.}, BoxStyle -> {},
  ClipPlanes -> None, ClipPlanesStyle -> Automatic, 
 ColorOutput -> Automatic, ContentSelectable -> Automatic, 
 ControllerLinking -> Automatic, ControllerMethod -> Automatic, 
 ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic, 
 DisplayFunction -> Identity, Epilog -> {}, FaceGrids -> None, 
 FaceGridsStyle -> {}, FormatType -> TraditionalForm, 
 ImageMargins -> 0., ImagePadding -> All, ImageSize -> Automatic, 
 ImageSizeRaw -> Automatic, LabelStyle -> {}, Lighting -> Automatic, 
 Method -> Automatic, PlotLabel -> None, 
 PlotRange -> {{-0.15, 0.15}, {-0.15, 0.15}, {-0.15, 0.2}}, 
 PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
 PreserveImageOptions -> Automatic, Prolog -> {}, 
 RotationAction -> "Fit", SphericalRegion -> False, 
 Ticks -> Automatic, TicksStyle -> {}, TouchscreenAutoZoom -> False, 
 ViewAngle -> Automatic, ViewCenter -> {0.5, 0.5, 0.5}, 
 ViewMatrix -> Automatic, ViewPoint -> {1.3, -2.4, 2.}, 
 ViewRange -> All, ViewVector -> Automatic, 
 ViewVertical -> {0., 0., 1.}}
POSTED BY: Anonymous User
6 Replies
Anonymous User
Anonymous User
Posted 7 years ago

the raytracer export/import with for smooth triag normals and some 2D plot ability - but all i have on-hand to show is an older ball/reflect image i did weeks ago

reflection

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 7 years ago

this shows area lighting (different from point lighting)

lighting

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 7 years ago

As you see, to get the "box" around the result of "just any Graphics3D", Rayshade[] has to have a good PlotRange or some way of determining it (ie, without extensive vertex and shape analysis of every Primitive Mathematica 11 has to "make a new plotrange" would be nice).

Sorry I just figured out that ViewCenter is in scaled coordinates - so that explains {.5,.5,.5}. Initial tests show that after all the grunt work is done (ie, finding box center, applying boxratios) the plotrange does work. (? arrows len 2 .8 is 1.6 which is 1/2 of .5+.3, roughly, is what i wasn't thinking of)

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 7 years ago

This is what using the Manipulation looks like sliding the lights for x. (the resolution must be lower to reasonably manipulate as the computation process is slower than typical output, the following takes a at a minute or two to make 32 frames of).

Attachments:
POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 7 years ago

Here's what the Manipulate looks like (no CDF yet).

Attachments:
POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 7 years ago

Here's why. I am (rendering) Mathematica 11 graphics with a package - which does about all I want before release except the BoxRatio question (which can be given by opts, but would be nicer if Automatic).

In[1470]:= Remove[x, y, z, x2, y2, z2, light, transp, amb, diff, \
extLight, size, frames, k]

In[1471]:= transp = .4;
light = 0.604;
amb = 0;
diff = 1;
extLight = False;
size = 1024;
{x, y, z} = {1, .001, 4};
{y2, z2} = {0.04, 0.88};
frames = 15;

In[1480]:= g = Graphics3D[{
    Text["rayshade-mathematica\nversion 11.0", {.2, 0, 0}, {0, 0}],
    {Glow[Yellow], RayInput["@ @ @ noshadow"], Sphere[{0, 0, 0}]},
    {
     Opacity[.4], RGBColor[.4, .4, 0], 
     Specularity[RGBColor[.8, .8, .8], 80],
     RayInput["@ @ @ reflect .4 index 1.1"],
     Sphere[{0, 0, .1}]
     },
    Blue, Specularity[RGBColor[.8, .8, .8], 60],
    RayInput["@ @ @ reflect .5"],
    Cuboid[{-1, -1, -1}, {1, 1, -.999}]}];

In[1494]:= Remove[list, x2, k];

In[1495]:= 
list = Table[
   Rayshade["r.orig.ray", 
    g /. {Opacity[.4] -> Opacity[transp], 
      Sphere[{0, 0, 0}] -> Sphere[1.2 {x2, y2, z2}, .1]}, 
    RayDefaultSurface -> extLight, RayShow -> False, 
    RayWatch -> False, 
    ViewVector -> {z vprot[x, y] + rayshade`Private`boxcenter, 
      rayshade`Private`boxcenter},
    RaySize -> {size, size}, RayRGBAdjust -> {amb, diff}, 
    LightSources -> {{{x2/frames, y2, z2}, 
       RGBColor[light 1.2, light 1.2, light]}},
    RayExtLight -> extLight, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}},
     PlotRangeClipping -> False, AspectRatio -> 1, 
    BoxRatios -> {1, 1, 1}, RayTubeLines -> True, 
    RayFastLight -> Not[extLight], RayRadiusExt -> .1], {x2, 
    Join[Table[k, {k, -.3 frames, .7 frames}], 
     Table[k, {k, .7 frames, -.3 frames, -1}]]}];

In[1496]:= Length@list

Out[1496]= 32

In[1497]:= If[Length@list >= frames, Export["Rayshade.gif", list]; 
 Remove[list]]

Out[1211]= Manipulate[rayshade`Rayshade["r.orig.ray", 
   g /. {Opacity[0.4] -> Opacity[transp], Sphere[{0, 0, 0}] -> 
      Sphere[1.2*{x2, y2, z2}, 0.1]}, rayshade`RayDefaultSurface -> \
extLight, 
   rayshade`RayShow -> False, rayshade`RayWatch -> False, 
   ViewVector -> {z*vprot[x, y] + rayshade`Private`boxcenter, 
     rayshade`Private`boxcenter}, rayshade`RaySize -> {size, size}, 
   rayshade`RayRGBAdjust -> {amb, diff}, LightSources -> 
    {{{x2, y2, z2}, RGBColor[light*1.2, light*1.2, light]}}, 
   rayshade`RayExtLight -> extLight, PlotRange -> 
    {{-1, 1}, {-1, 1}, {-1, 1}}, PlotRangeClipping -> False, 
   AspectRatio -> 1, BoxRatios -> {1, 1, 1}, rayshade`RayTubeLines -> \
True, 
   rayshade`RayFastLight ->  !extLight, rayshade`RayRadiusExt -> 0.1], 
  {{x, 1, "rotate"}, -2*Pi, 2*Pi}, {{y, 0.0009999999999725784, \
"height"}, 
   -1.5715821178538232, 1.5715821178538232}, {{z, 4, "zoom"}, -8, 8}, \

  {{x2, 0.7, "lights x"}, -4, 4}, {{y2, -0.7000000000000002, "lights \
y"}, -8, 
   8}, {{z2, 0.88, "lights z"}, -4, 4}, {{light, 0.604, 0.604}, \
0.001, 1}, 
  {{transp, 0.44, "transparency"}, 0.01, 1}, {{amb, 0, "ambience"}, \
0, 5}, 
  {{diff, 1, "diffusion"}, 0, 5}, {{extLight, False, "Area Light"}, 
   {False, True}}, {{size, 128, "size"}, 64, 4096}, 
  SynchronousUpdating -> False, TrackedSymbols :> 
   {x, y, z, x2, y2, z2, light, transp, amb, diff, extLight, size}]
POSTED BY: Anonymous User
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract