POV-Ray : Newsgroups : povray.binaries.images : Mesh2 bug? [JPG, 800 x 600, 42881 bytes] : Re: Mesh2 bug? [JPG, 800 x 600, 42881 bytes] Server Time
9 Aug 2024 09:05:06 EDT (-0400)
  Re: Mesh2 bug? [JPG, 800 x 600, 42881 bytes]  
From: Mike Williams
Date: 25 Apr 2005 07:47:52
Message: <f737gDAPjNbCFwbC@econym.demon.co.uk>
Wasn't it Slime who wrote:

>The other thing, as Gilles pointed out, is to check whether your mesh data
>actually *is* a series of disconnected triangles! Look at your data
>carefully to rule this out.

He posted an earlier version of his source code a while ago. Each vertex
is listed once and then used in all the adjoining triangles.

It is floating point precision problems. The points are typically at a
distance of 6378140 POV units from the origin (The Earth's radius in
metres). The short sides of the triangles are somewhere in the region of
33400 POV units, so I guess than an error of a few tens of units would
be visible in this image.

Scaling the whole mesh down doesn't help, because it's the ratio of the
error to the size of the number that's significant.

One way to fix it is to move the whole mesh so that the point being
looked at is placed close to the origin, by subtracting the "look at"
point from the data read from the SRTM file before calculating the mesh.
The calculated mesh can then be translated back to the required
position.

I did some experiments. Not having a copy of the SRTM data, I just set
all heights to sea level. Not having masses of memory on my computer, I
severely reduced the number of triangles, but was still able to
reproduce the problem and work round it by making the following changes:

1. Move the calculation of lNormVect to close to the start of the scene 
   and use it to get an approximate look at point. (We can't get the 
   exact look at point yet because that requires tracing the mesh.)
   We don't need an exact value.

      #declare ApproxLook = vnormalize(lNormVect) * (rp+re)/2;

2. Move the vertices by minus that vector when creating the mesh

      #while (b<l)
        <(re+mtrix[a][b]) * sin ((sLong-b/l) * (pi/180)) *
        cos ((sLat + a/l) * (pi/180)),
        (rp+mtrix[a][b])*sin((sLat+a/l)*(pi/180)),
        (re+mtrix[a][b]) * cos ((sLong-b/l) * (pi/180)) *
        cos ((sLat+a/l)*(pi/180))> - ApproxLook

3. Translate the whole mesh back to where you want it (at the end of the
   Earthslice declaration, just before its final "}").

        translate ApproxLook


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.