1
votes

I've been using the command posted some years ago here about how to obtain data points from a 2D-function:

f = Sin[t];
plot = Plot[f, {t, 0, 10}]
points = Cases[
   Cases[InputForm[plot], Line[___], 
    Infinity], {_?NumericQ, _?NumericQ}, Infinity]; 

And export it to a data file:

Export["data2/name_"<>ToString[N[index]]<>"&"<>ToString[N[a]]<>".dat",points1,"Table","FieldSeparators"->" "];

However, right now I must generalize this command for the 3Dplot case, I've tried to look at the documentation about Cases and List3Dplot commands but unfortunately I have not been able to figure it out. Anyone has a suggestion? I'd appreciate it a lot. Thanks.

1
this answer : stackoverflow.com/a/5364257/1004168 to the 2d question should work for Plot3D. (and note the comment I made to that) - agentp

1 Answers

1
votes

using Cases :

Flatten[Cases[
   InputForm@Normal@Plot3D[Sin[x y], {x, -1, 1}, {y, -1, 1}]  , 
   Polygon[x_, ___] -> x, Infinity], 1] // Union

using EvaluationMonitor:

Reap[Plot3D[z = Sin[x y], {x, -1, 1}, {y, -1, 1}, 
   EvaluationMonitor :> Sow[{x, y, z}]]][[2, 1]];