draw a surface from a matrix of points in asymptote latex

Let \$S\$ be a surface in \$\mathbb{R}^3\$. I have a large set of points \$(x, y, z)\$ belonging to this surface, and I want to draw it using Asymptote in LaTeX. Here is the version of my code that is not working since it complies with no error but no result is produced. Thank you in advance.

``````import three;
size(200);
currentprojection = perspective(6,3,2);
file in = input("xyz.dat").line();
real[][] a=in;
a=transpose(a);
real[] x = a[0];
real[] y = a[1];
real[] z = a[2];
triple[][] points;
for (int i = 0; i < x.length; ++i) {
triple[] currentPoint = {(x[i], y[i], z[i])};
points.push(currentPoint);
}
surface s = surface(points);
draw(s);
``````
• Are you sure there is no error? Running your code on asymptote 2.86, I get an error on `no matching function 'surface(triple[][])'`. Jul 14, 2023 at 1:01
• it compiles with no errors in Asymptote version 2.78 Jul 14, 2023 at 22:35
• it compiles with no errors in Asymptote version 2.78 Jul 14, 2023 at 22:35
• What do you mean by a surface? What you have is a cloud of points only as far as I can see. Aug 25, 2023 at 13:13

First, the `surface(triple[][])` is part of `graph3`, and not `three`. So you need to `import graph3;` instead.
Secondly, if I read your code correctly, your code stuff all of `xyz.dat` into essentially a one-dimensional array of `triples` (it has width just 1). This will not work for `surface`; the function `surface(triple[][])` builds a wire frame parametrized by the two array dimensions. The way you are stuffing the info into the array, there is no surface to plot, as the whole thing is interpreted as a one dimensional curve.