I am having trouble plotting curves on surfaces. I have searched for similar examples and I have tried both Plot3D and ParametricPlot3D commands and experimented with Epilog and MeshFunctions (et.c) without success.

Goal: to plot a curve and a line segment (or, it could be a vector) on a surface. The curve follows the surface.

The Sin[x] function is a reasonable surface although my surface I am using is constructed via a ParametricPlot3D command from an Interpolation function generated from data numerically computed by an external program.

But, if I know how to do this with Sin[x] via ParametricPlot3D I can do it with my Interpolation function.

Here is a Sin[x] function plotted using:

Notice that a surface and a curve is plotted, the curve being the 2sinx2sinx2\sin{x} value along y=2y=2y=2. I have not yet figured out how to highlight the curve with different color or thickness but that is not may main question. I would like to have this 2sinx2sinx2\sin{x} curve run from points (2.3,2)→(4.0,2)(2.3,2)→(4.0,2)(2.3,2)\rightarrow (4.0,2) only and of course highlighted by a different color. Another line (on the surface) would extend from points (2.3,2)(2.3,2) to (4.0,4)(4.0,4).

Help?

=================

=================

2 Answers

2

=================

Your problem was that your line did not depend upon yy. ParametricPlot3D functions use both variables and produces fundamentally two-dimensional surfaces when you have two variables.

ParametricPlot3D[{

{x, y, 2 Sin[x]},

{x, 2 + y/50, 2 Sin[x]}

},

{x, 0, 3 Ï€}, {y, 0, 6},

PlotStyle -> {{Opacity[0.5], Pink}, {Black}}]

Best is to make the plot of the line a function of just one variable:

a = ParametricPlot3D[

{x, y, 2 Sin[x]},

{x, 0, 3 Ï€}, {y, 0, 6},

PlotStyle -> {Opacity[0.5], Pink}];

b = ParametricPlot3D[{x, 2, 2 Sin[x]},

{x, 0, 2 Ï€},

PlotStyle -> Blue];

Show[a, b]

I attempted to mark as answer but it is not working for some reason. But, this worked and I am kicking myself (not too easy to do though) because I did not realize the solution you posted — I should have.

– K7PEH

May 24 at 17:59

I now see that the answer mark is posted — had to refresh the page though.

– K7PEH

May 24 at 18:00

You can also use the options Mesh and MeshFunctions with a single ParametricPlot3D:

a = 2; b = 2 Pi;

ParametricPlot3D[{u, v, 2 Sin[u]}, {u, 0, 3 Pi}, {v, 0, 6},

MeshFunctions -> {# &, #2 &, ConditionalExpression[#2 – 2, a <= # <= b] &},
Mesh -> { 15, Range[0, 6, .5], {{0, Directive[Thick, Red]}}}]