Performance of Rhino.Geometry.Surface.IsSphere(tolerance)

Is IsSphere supposed to work on non-rational NurbsSurfaces? If so, it is not returning True for some surfaces that are within tolerance. For example, for surfaces made by using _Rebuild on a Ø8.0 _Sphere, the method’s threshold is between:

  • 79x79 and 80x80 CV’s for 3x3 degree surfaces
  • 19x19 and 20x20 CV’s for 5x5 degree surfaces

This can be verified using the following script on IsSphere.3dm (407.8 KB)

import rhinoscriptsyntax as rs

def main():
    
    idBrep = rs.GetObject("Select sphere", filter=rs.filter.surface, preselect=True)
    if idBrep is None: return
    
    rgFace = rs.coercesurface(idBrep)
    
    for e in range(-11, 1):
        tol = 10.**e
        if rgFace.IsSphere(tol):
            step = tol/100.
            for tol in rs.frange(tol/10.+step, tol+step, step):
                if rgFace.IsSphere(tol):
                    print "IsSphere returns True at a tolerance of {}.".format(tol)
                    return
    else:
        print "IsSphere returns False even at a tolerance of {}.".format(tol)

if __name__ == "__main__": main()

Thank you,
Steve

Yes it should. The function does a number of tests to determine whether or not a surface is a sphere. In order to tell why why the function turns false in some cases, I’d have to look at each case individually.

Is there a particular problem you are trying to solve with this?

I am creating a kind of surface version of _SimplifyCrv.