3
$\begingroup$

I have a 2D surface in 3D space ContourPlot3D[{c*f*h^2 == 4214 }, {c, 0, 100}, {f, 0, 10}, {h, 0, 33.4}]that is tangent to a line ParametricPlot3D[{20, 8 - (3/5)*h, h}, {h, 0, 33.4}, PlotStyle -> Red]. The line corresponds to the intersection of the constraints of a maximization problem while, the surface corresponds to the surface level of the objective function evaluated at the solution of the maximization problem. When I see the graph from below it appears that the line is indeed tangent but when I look at it from above, it appears as it is crossing the surface from above which is not true. I even rounded up the value of the surface level which should raise it up. I also tried to style the curve as Thin but it did not make a difference.

enter image description here above view

$\endgroup$
1
  • $\begingroup$ The line is in fact not even tangent at that point to the surface but is so close in a quite long range that it cannot be depicted correctly. But I mean not that it is a bug in Mathematica but that it can not be depicted in general. $\endgroup$ Commented Jan 26 at 16:52

2 Answers 2

4
$\begingroup$

One workaround, changing the rendering engine changes how elements that are approximately in the same position are rendered:

Show[{ContourPlot3D[{c*f*h^2 == 4214}, {c, 0, 100}, {f, 0, 10}, {h, 0,
     33.4}], 
  ParametricPlot3D[{20, 8 - (3/5)*h, h}, {h, 0, 33.4}, 
   PlotStyle -> Directive[Red]]},
 BaseStyle -> 
  RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}]

enter image description here

Changing the view point suggests that z-fighting is a factor:

{ContourPlot3D[{c*f*h^2 == 4214}, {c, 0, 100}, {f, 0, 10}, {h, 0, 
    33.4}], ParametricPlot3D[{20, 8 - (3/5)*h, h}, {h, 0, 33.4}, 
   PlotStyle -> Directive[Red]]};
movie = Table[
   Show[%, ImagePadding -> 25, Axes -> False(*,PlotLabel->k*), 
    ViewPoint -> 6.^(k^2/6) {1.3, 2.4, 2.}], {k, 7}];

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ In V13 or V14 (sorry, I can't remember — maybe it was even earlier), drawing lines on surfaces was improved, which can be difficult if the polygon edges and line vertices do not coincide. I don't know the method WRI uses, but perhaps it treats distances that are approximately the same as equal. The part of the red line that bleeds through may consist of pixels where the line and surface are close to each other. It's not that the line is drawn "above" but that it is drawn "on" the surface. Maybe. $\endgroup$
    – Goofy
    Commented Jan 27 at 14:38
  • $\begingroup$ The surface and the line touch only at one point. $\endgroup$ Commented Jan 30 at 15:53
  • 1
    $\begingroup$ @SergioParreiras Thanks for the accept. About the surface and line touching at only one point, that is what I understood. But I also understood that in the code provided, you "rounded up the value of the surface level which should raise it up," which makes the surface and line separate very slightly. (It can be shown with Mma that the separation is on the order of 10^-6, IIRC.) $\endgroup$
    – Goofy
    Commented Jan 31 at 19:56
3
$\begingroup$

You can see what is going on in 2D.

{c*f*h^2 == 4214, f == 8 - (3/5)*h} /. c -> 20
N[Solve[%], 10]
ContourPlot[Evaluate@%%, {f, 0, 10}, {h, 0, 33.4}]

{20 f h^2 == 4214, f == 8 - (3 h)/5}

{{f -> 10.66666898, h -> -4.444448302},
 {f -> 2.666665509 + 0.004303314 I, h -> 8.888890818 - 0.007172190 I},
 {f -> 2.666665509 - 0.004303314 I, h -> 8.888890818 + 0.007172190 I}}

enter image description here

From Solve you see that the line intersect the surface only in a single point {f -> 10.66666898, h -> -4.444448302} which is not of our interest.

The point of our interest is the other "double" point {f -> 2.666665509 ± 0.004303314 I, h -> 8.888890818 ∓ 0.007172190 I} which is in fact complex.

From the plot you can see that even in 2D you can not tell by eyes whether the line intersect the curve or touches it or misses it.

Only Solve tells you that the curve and line misses each other around that point.

I think from all of this follow that you can not do any better depiction in 3D.

$\endgroup$
2
  • 2
    $\begingroup$ The tangent line does not like tangent to a curve is a constant bug in Windows but not in Linux. mathematica.stackexchange.com/a/274508/72111 $\endgroup$
    – cvgmt
    Commented Jan 27 at 0:48
  • 2
    $\begingroup$ @cvgmt: As far as I can see - in the link the problem is in GeometricTest not in Graphics. The graphics is drawn correctly the ellipses indeed intersect with the lines. The point is that the lines were incorrectly computed by GeometricTest. $\endgroup$ Commented Jan 27 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.