Freesteel Blog » Triangulating a sphere

Triangulating a sphere

Monday, July 15th, 2013 at 11:47 am Written by:

Suppose I have a sphere of radius 5mm. I need it to be triangulated to a tolerance of 0.01mm.

This is the answer I would like to get:

Unfortunately, this is the answer I’m going to get from almost all CAD systems:

This could be any shape, but I’m showing a sphere because the issue is easy to understand. There are too many triangles at the poles and it’s not particularly optimal.

Why do I want a triangulation to a tolerance? Because I am doing some machining, printing, simulation, or visualization that depends on triangles, and my algorithm is going to run faster the fewer triangles there are.

Sure, you could theoretically perform these calculations using the “true” surface to a sample point value of 14 decimal places, but I only want it to two decimal places, because that’s going to be faster, cheaper and fit for purpose. I have no use for 14 decimal places. Just because analytical calculations and their iterative numerical solutions cannot deliver the answer to anything other than 14 decimal places, doesn’t mean it’s useful. In my book, precision engineering means to the defined precision, where less precision is proportionately cheaper and quicker to engineer. We don’t want the smelly oil sump guard to cost as much to manufacture as the finely tuned impeller in the diesel pump; it’s only got to be accurate enough to fit the gasket and not get in the way. That’s how we get performance out of a system — by focusing resources away from where it is not needed, and into the places where it makes a difference.

Anyway, where was I?

That’s it. Triangulating the sphere of radius 5 to a tolerance of 0.01.

Now, if you divide the meridian of the sphere into 50 segments, and the equator into 50 segments (so it is a 50 sided polygon), you can achieve this tolerance along the lines of longitude and latitude, according to the following calculation:

t = 360/50 = 7.2degrees
centre = (0, 0, 0)
    p0 = (5, 0, 0)
    p1 = (5*cos(t), 0, 5*sin(t)) = (4.961, 0, 0.627)
    p2 = (5*cos(t), 5*sin(t), 0) = (4.961, 0.627, 0)

p0p1 deviation (at the mid-point of the line segment) 
       = 5 - |(p0 + p1) / 2| = 5 - |(4.980286,0,0.313333)|
                             = 5 - sqrt(4.980286*4.980286 + 0.31333*0.313333)
                             = 0.009866 < 0.01

Same for p0p2, and all other line segments in the mesh, where the non-equatorial lines of latitude have smaller radii and so have smaller deviations from the sphere.

But what about the points in the middle of the triangle? Who cares about the middles of triangles? I care. And so does everyone else who depends on this, even if they don't understand it.

Here the deflection from the surface is even greater because the two-way curved surface bulges further away from flatness of the triangle.

Pick a point in the middle of the triangle:

s = (p0+p1+p2)/3 = (4.97371,0.208888,0.208888)
5 - |s| = 0.017519

which is greater than the tolerance I asked for.

Not a lot of people know that.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>