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;
currentprojection = perspective(6,3,2);
file in = input("xyz.dat").line();
real[][] a=in;
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])};
surface s = surface(points);
  • 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
    – rihani
    Jul 14, 2023 at 22:35
  • it compiles with no errors in Asymptote version 2.78
    – rihani
    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

1 Answer 1


There are several issues, I think.

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.

  • how to solve these issus, if you have an idea i will be grateful
    – rihani
    Jul 14, 2023 at 22:35
  • if you have some control over the data file, then the easiest way is to make sure your data is in similar format to what is looked for. otherwise, you have to figure out how to define a triangulation based on the points that are available. This is a problem in computational geometry that presumably people have worked on. Jul 15, 2023 at 1:53
  • For example, google search shows me this master's thesis diva-portal.org/smash/get/diva2:643168/FULLTEXT01.pdf Jul 15, 2023 at 1:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .