Rs.SurfaceCurvature() bug in Python?


#1

Hi ,

I’m calling rs.SurfaceCurvature() in python to obtain the surface normal vector at a particular point at a surface. After rendering the normal vector (see code below), the normal vector seems to be always pointing in the same direction, even if the surface is flipped via the command “dir” or its python equivalent. The vector is definitely normal to the surface, but it does not particularly point in the correct direction…

@stevebaer, is this the expected behavior? Or is this a bug?


import rhinoscriptsyntax as rs

srf = rs.GetObject("Select a surface", rs.filter.surface)

def renderVector(vecdir, base_point):
    tip_point = rs.PointAdd(base_point, vecdir) 
    line = rs.AddLine(base_point, tip_point) 
    if line: return rs.CurveArrows(line, 2)

if rs.IsSurface(srf):

    point = rs.GetPointOnSurface(srf, "Pick a test point")

    if point:

        param = rs.SurfaceClosestPoint(srf, point)

        if param:

            data = rs.SurfaceCurvature(srf, param)

            if data:

                print "Surface curvature evaluation at parameter", param, ":"

                print "  3-D Point:", data[0]

                print "  3-D Normal:", data[1]

                print "  Maximum principal curvature:", data[2], " ", data[3]

                print "  Minimum principal curvature:", data[4], " ", data[5]

                print "  Gaussian curvature:", data[6]

                print "  Mean curvature:", data[7]

                renderVector(data[1], data[0])
                    

I don’t know if this is pertinent info, but the particular surface that I’m observing this was created with 4 edges using rs.AddEdgeSrf().

Thanks,
Bruno


#2

rs.SurfaceNormal() seems to do what I want. Not entirely sure why the normal vector returned by rs.SurfaceCurvature() is not the same as rs.SurfaceNormal()…

Regards,
Bruno


(Menno Deij - van Rijswijk) #3

The normal can be in “flipped” state on a BREP object (which all surfaces are in Rhino). Using the Dir command, you can change the normal and see a small blue line appear. This means that the normal is flipped on the surface.

Probably rs.SurfaceNormal() incorporates the flipped state, whereas the underlying surface keeps its normal, so rs.SurfaceCurvature() does not take into account the flipped state.


#4

Got it Menno. Thanks for the explanation!

Cheers,
Bruno