Message Boards Message Boards

0
|
7314 Views
|
12 Replies
|
7 Total Likes
View groups...
Share
Share this post:

[?] Stop this clipping in Graphics3D?

Anonymous User
Anonymous User
Posted 7 years ago

When I do this,

Graphics3D[{Sphere[{-1, 0, 0}], Sphere[{0, 0, 0}], 
  Sphere[{+1, 0, 0}]}, Axes -> True, PlotRange -> Full, Boxed -> True]

I get this:

enter image description here

What can I change to eliminate the clipping that's shown (spheres chopped off halfway)? The only boundary I want to cause clipping is the red rectangle that's shown.

Furthermore, I am Animating this type of graphic, to simulate spheres moving through 3D-space over time, and I want the virtual-camera position to remain constant over time. I want a fixed virtual-camera in a fixed virtual-space, with only the spheres in motion. I want the red rectangle to stay a constant shape, and I want the bounding-box to remain a constant shape too, at a fixed position within the red rectangle (or possibly I'd be better off with no bounding-box, but I'm not sure).

When I try changing Boxed to False, the bounding box is no longer displayed, but its boundaries continue to clip the spheres.

When I try changing PlotRange to All, the shape of the red rectangle varies according to the varying positions of the spheres; but I want the shape of the red rectangle to remain constant instead.

I have investigated all the Graphics3D-options that seem to me like they might help, but I still have found no solution.

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

I'm trying to make a movie about planets interacting under gravity, but when I try this with Mathematica, the movie show the planets getting chopped in half and then disappearing when they leave the boundaries of a "bounding box". I don't want the planets to suddenly disappear. Is there any way to solve this problem? This is not supposed to be a movie about planets getting chopped in half or disappearing.

enter image description here

POSTED BY: Anonymous User
Posted 7 years ago

What you need seems to be a combination of PlotRange->All, ViewAngle and ViewVector. For example:

Manipulate[
 Framed[
  Graphics3D[{Sphere[{-sep, 0, 0}], Sphere[{0, 0, 0}], 
    Sphere[{sep, 0, 0}]}, Axes -> False, PlotRange -> All, 
   Boxed -> False, SphericalRegion -> False, ViewAngle -> 35*Degree, 
   ViewVector -> {{-5, 5, 2}, {0, 0, 0}}, ImageSize -> {300, 400}],
  FrameMargins -> None],
 {{sep, 0, "Separation"}, 0, 5, Appearance -> "Labeled"}]

enter image description here

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

Thanks. That looks like what I'm after. I'll study your code.

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

Thanks everyone for the advice. I'll see if I can get the results I'd like.

POSTED BY: Anonymous User

I'm not exactly sure what is desired, but fixing ViewAngle seems to correspond to its description:

Graphics3D[{Sphere[{-1, 0, 0}], Sphere[{0, 0, 0}], 
  Sphere[{+1, 0, 0}]}, Axes -> True, PlotRange -> All, Boxed -> True, 
 ViewAngle -> 10*Degree]
POSTED BY: Michael Rogers
Anonymous User
Anonymous User
Posted 7 years ago

I'm not exactly sure what is desired

I want it to look like Hans Milton's example, except the spheres would not be clipped by that 3D box. The spheres would be visible until they reach the gray border outside the white rectangle.

Imagine you are making computer-generated graphics for a movie to appear in Hollywood, and the producer wants you make spheres that move across the movie screen. The spheres should be visible until they move off the movie screen. The spheres should not be clipped by a 3D box before they reach the edge of the movie screen.

POSTED BY: Anonymous User

Sounds like my approach, which is similar to Chris P's, is on the right track, then, yes? As Chris shows, there are other view parameters, and you can use them to set up your shot in just the way you want. The most general one is ViewMatrix. It can take some effort to solve the geometry problem, though. This post on StackExchange has a nice picture showing the principal view parameters: https://mathematica.stackexchange.com/questions/3528/extract-values-for-viewmatrix-from-a-graphics3d/3538#3538

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

Yes, your approach yields a result that looks like what I want. I didn't say so earlier, because your code had options I'm not familiar with, so I was waiting til I had time to evaluate it. Now that I see what it evaluates to, that is what I'm after. Thank you.

And thank you for the additional link to Stack Exchange.

POSTED BY: Anonymous User
Posted 7 years ago

Maybe the option SphericalRegion->True could be of help

Manipulate[
    Graphics3D[
     {
        Sphere[{-Cos[\[Theta] \[Degree]] sep, 0, -Sin[\[Theta] \[Degree]] sep}],
        Sphere[{0, 0, 0}], 
        Sphere[{Cos[\[Theta] \[Degree]] sep, 0, Sin[\[Theta] \[Degree]] sep}]
        },
     Axes -> False, PlotRange -> {{-2, 2}, {-1, 1}, {-1, 1}},
     Boxed -> True, SphericalRegion -> True 
    ],
    {{\[Theta], 0, "Angle around Y"}, -180, 180, Appearance -> "Labeled"},
    {{sep, 1, "Separation"}, 0, 3, Appearance -> "Labeled"}
 ]

enter image description here

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

Thanks. I have tried that now, but it does not solve the problem of the unwanted clipping.

POSTED BY: Anonymous User
Posted 7 years ago

You really need to specify an explicit PlotRange setting if you don't want any surprises. That is, you should (or are supposed to) have an idea about the bounds of your objects at any point in your animation, and then set PlotRange to the extreme values of those bounds.

As a concrete example: if the $y$-range of one frame of your animation is {-5, 4}, and another frame has the range {2, 6}, then you need to set {-5, 6} as the range for $y$, and similarly for the other two dimensions.

POSTED BY: J. M.
Anonymous User
Anonymous User
Posted 7 years ago

Thanks. I have done that now, but it has not solved the problem of the unwanted clipping.

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