Reputation: 41
Is it possible to visualize the intersection of multiple surfaces with gnuplot:
set parametric
set hidden3d
set samples 25
set isosamples 25
splot u,v,0
replot u,0,v
The two surfaces I am trying to plot in this example are two planes. How can I visualize the intersection of these two planes ?
Upvotes: 2
Views: 2159
Reputation: 7627
Numerically, this can be done by setting the samples and defining the corresponding restriction interval. For example, imagine you want to plot your planes in the intervals x = [-1:1], y = [-1:1] and z = [-1:1], and use 101 samples in each direction:
set parametric ; set hidden3d
set isosamples 101
set xrange [-1:1]
set yrange [-1:1]
set zrange [-1:1]
splot u,v,0, u,0,v
Now, each of the 101 samples corresponds to an interval which has width (1 - (-1))/(101-1) = 0.02. If I constrain the distance between planes to be below half this threshold for plotting points, that is abs(u-u) < 0.01, abs(v-0) < 0.01 and abs(0-v) < 0.01 I will get exactly one point sampled for every interval along every direction:
set parametric ; set hidden3d
set isosamples 101
set xrange [-1:1]
set yrange [-1:1]
set zrange [-1:1]
splot (abs(u-u) < 0.01 ? u : 1/0), \
(abs(v-0.) < 0.01 ? v : 1/0), \
(abs(v-0.) < 0.01 ? 0 : 1/0)
where ? something : 1/0
means if condition before ?
is satisfied plot something
else ignore that point, then I have the intersection:
Upvotes: 2