# Extract points from ParametricPlot3D

I have this ParametricPlot3D

sigma = 10;
rho = 27;
beta = 8/3;
sol = NDSolve[{x'[t] == sigma (y[t] - x[t]),
y'[t] == x[t] (rho - z[t]) - y[t], z'[t] == x[t] y[t] - beta z[t],
x == 0, y == 1, z == 1.05}, {x, y, z}, {t, 0, 100},
MaxSteps -> 30000];
p = ParametricPlot3D[Evaluate[{x[t], y[t], z[t]} /. sol], {t, 0, 100},
ColorFunction -> Function[{x, y, z}, Hue[x]], PlotPoints -> 250] I would like to extract the data points in the form of a list {{x1,y1,z1},{x2,y2,z2},...} and so I did this

data = Cases[p, GraphicsComplex[x__] -> x, {1}][];


But the points do not seem to be in the right order, in fact the first number is not my inizial value (0,1,1.05), nor is the last one. If I do

Graphics3D@Line@data


this is the result which is all messed up. How can I extract the points from the plot in the right order?

• Try this: data = Cases[Normal[p], Line[pts_] :> pts, ∞][]. – J. M. will be back soon Mar 24 '17 at 15:28
• Wow, that worked, thank you very much! Could you explain your code a little bit, what is Normal doing exactly and why using RuleDelayed instead of the usual rule? – Emmet Mar 24 '17 at 15:34
• maybe missing the point of the question, but you can ge the points right from the NDSolve result: Graphics3D@Line[Transpose[Through[{x, y, z}["ValuesOnGrid"]] /. First@sol ]] – george2079 Mar 24 '17 at 15:52
• Plot can give you fewer points as needed to generate a smooth curve. (Example if you set a small MaxStepSize in NDSolve, Plot will just take the points it needs.). In this case about the same.. I kind of like having the actual calculated points, not interpolated. – george2079 Mar 24 '17 at 16:13
• @george2079 I see, good point. If anybody is curious, in this case using data2 = Transpose[Through[{x, y, z}["ValuesOnGrid"]] /. First@sol] I get 12520 points while data = Cases[Normal[p], Line[pts_] :> pts, ∞][] gives me 13110. – Emmet Mar 24 '17 at 16:23