TransWikia.com

The intersection point of a line crossing a surface is not displayed correctly In 3D Graphics

Mathematica Asked on December 19, 2021

This is my code:

Show[{ParametricPlot3D[{x, y, 0}, {x, -4, 4}, {y, -4, 4}, 
   PlotStyle -> LightGray, Mesh -> None],
   ParametricPlot3D[{0, 0, t}, {t, -8, 8}, PlotStyle -> Blue],
   ParametricPlot3D[{x, 0, z}, {x, -3, 3}, {z, -3, 3}, Mesh -> None]}]

Output out put

I noticed that the intersection point of the vertical line with the horizontal plane is not on the intersection line of the two planes, although the vertical line is defined on the vertical plane. By setting the axes of the Plot at the origin, I found that the intersection line of two planes is displayed correctly.

So my questions why the insection point of the vertical line with the horizontal plane is not displayed right? How can I make it right? Thanks a lot!

2 Answers

Use the "BSPTree" rendering method as this doesn't suffer from z-buffer precision issues and produces crisp edges:

theplot = 
  Show[{ParametricPlot3D[{x, y, 0}, {x, -4, 4}, {y, -4, 4}, 
     PlotStyle -> LightGray, Mesh -> None], 
    ParametricPlot3D[{0, 0, t}, {t, -8, 8}, PlotStyle -> Blue], 
    ParametricPlot3D[{x, 0, z}, {x, -3, 3}, {z, -3, 3}, 
     Mesh -> None]}];

GraphicsRow[{
  theplot
  , Style[theplot, RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}]
}]

compare graphics

Notice how the blue line juts out over the plane by a tiny fraction on the left image, but the right image renders correctly and uses BSP trees for visibility testing instead of a z-buffer.

Answered by flinty on December 19, 2021

It's a matter of viewpoint. I am using Windows 10 and MMA 12.0 and most other viewpoints had rendering looking a bit more precise.

I also changed the order of the three graphics, but the rendering stayed the same as yours.

c = ParametricPlot3D[{x, y, 0}, {x, -4, 4}, {y, -4, 4}, 
PlotStyle -> LightGray, Mesh -> None];
d = ParametricPlot3D[{0, 0, t}, {t, -8, 8}, PlotStyle -> Blue];
e = ParametricPlot3D[{a, 0, b}, {a, -3, 3}, {b, -3, 3}, Mesh -> None];
Show /@ Permutations[{c, d, e}]

We probably should have wrapped these in Module as part of best practices, especially since x and y show up in several places.

Answered by zeattledave on December 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP