1
$\begingroup$

Let's consider an example:

Case 1:

rdata = Table[Sin[u + v^2] + RandomReal[], {u, 0, 3, .2}, {v, 0, 4, .2}];
w1 = ListPlot3D[rdata, Mesh -> All]
w2 = ListPlot3D[rdata, Mesh -> All, ViewPoint -> {0, 0, 1}]

How on the basis of the set rdata = {r1, r2, r3}, determine the set points of the data r3 (points is a matrix with the dimension $m \times n$) which can be seen in the figures w1 and w2?

points =(* 'm x n' matrix *)

ReliefPlot[points, ColorFunction -> "GreenBrownTerrain"] (*?????*)

Case 2: (more important for me):

rdata = Table[{x = RandomReal[{0, 1}], y = Sin[RandomReal[{0, 1}]], Cos[RandomReal[]]/5}, {2000}];

...the remaining part as in the 'case 1'.

$\endgroup$
1
  • $\begingroup$ Hint: Use backticks (`) instead of (') for markup. $\endgroup$ Jan 27, 2018 at 7:47

1 Answer 1

1
$\begingroup$

This is not exactly what you ask for but if it is about interpolation, you can use ListInterpolation with an InterpolationOrder of your choice:

f = ListInterpolation[rdata, InterpolationOrder -> 3];

Now you can use as a function from the plane to the reals, e.g. Map it over other lists of points in the plane.

Here is a plot with the data points in order to show how the list gets interpolated:

{m, n} = Dimensions[rdata];
pts = Join[Outer[List, Range[m], Range[n]], Map[List, rdata, {2}], 3];
w0 = Graphics3D[Sphere[Flatten[pts, 1], 0.1]];
w3 = Plot3D[f[s, t], {s, 1, m}, {t, 1, n}, PlotPoints -> 5 {m, n}, Mesh -> {m - 2, n - 2}];
Show[w0, w3]

enter image description here

When interpolating 3D points that are supposed to lie one a graph, then Interpolation can be used. If the $(x,y)$-points do not live on a regular quad grid then only InterpolationOrder->1 is supported. Note that the syntax {{x,y},z} has to be used.

n = 2000;
x = RandomReal[{0, 1}, n];
y = RandomReal[{0, 1}, n];
z = Sin[2 Pi x + Pi y]/5.;
rdata = Transpose[{Transpose[{x, y}], z}];
f = Interpolation[rdata, InterpolationOrder -> 1];

This interpolates the data over a triangle mesh, proabably the 2D-DelaunayMesh". This is how you can draw the resulting function:

R = DelaunayMesh[Transpose[{x, y}]];
Show[
 Graphics3D[Sphere[Flatten /@ rdata, 0.01]],
 Plot3D[f[s, t], {s, t} ∈ R, Mesh -> All]
 ]

enter image description here

While the interpolation in the interior parts of the domain deem to be good, be cautious when using the interpolating function f close to the boundary of the domain.

ReliefPlot also expects the height values to lie on a quad grid; you can generate such a grid and sample f over it to create data that ReliefPlot can eat:

m = 200;
n = 200;
heights = Apply[f,
   Outer[
    List,
    Subdivide[0.2, 0.8, m],
    Subdivide[0.2, 0.8, n]
    ], {2}];
ReliefPlot[heights, ColorFunction -> "GreenBrownTerrain"]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you. We can obtain the sought set: points= Split[Flatten[pts, 1], #1[[1]] == #2[[1]] &][[All,All,3]]; ....There is still a problem with 'Case 2'. $\endgroup$
    – ralph
    Jan 27, 2018 at 9:43
  • $\begingroup$ While earlier it was easy to generate a matrix 'm x n' ('points') so now I do not know how to do it. I just have to use the ReliefPlot[] function to draw a set 'points'. $\endgroup$
    – ralph
    Jan 28, 2018 at 10:02

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.