Question

i read some code of terrain genration,

x = 0.25 * randn(3, 1);
y = 0.25 * randn(3, 1);
h = 0.1*randn(3, 1);
trisurf(delaunay([-1; -1; 1; 1; x], [-1; 1; -1; 1; y]), ...
        [-1; -1; 1; 1; x], [-1; 1; -1; 1; y], [0; 0; 0; 0; h]);

the delaynay fucntion parameter's meaning i am little confused. i googled and the usage often is delaunay(x,y).

Can anyone give some hints?

Was it helpful?

Solution

Breaking it down a little bit - you have

delaunay(V1, V2)

Inside another call

trisurf(M1, M2, M3, M4);

The thing you were struggling with was the delaunay call - it has two parameters as usual (V1, V2. The only odd thing is that four numbers were added.

V1 = [-1;-1;1;1;x];
V2 = [-1;1;-1;1;y];

These four additional (x,y) pairs represent the four corners of a square, and make sure that the figure does not have ragged edges. The same values had to be added to the X, Y, Z coordinates for the trisurf plot so vectors corresponded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top