Forgot password?

Create an account!

Forum

« back

RhinoScript – curvecurvature

Messages

Please log in to write a message.

  • 2. Hanno (Oct 16, 2009 00.23):

    Hi,

    just some quick thoughts:

    rhino.curvecurvature can return NULL (e.g. if your curve is straight). Maybe that's the problem.
    And rhino has some built-in vector methods like rhino.vectoradd and rhino.vectorunitize, so you don't have to write these things yourself :-)

    Regards

    Hanno

  • 1. moodo (Oct 14, 2009 14.53):

    Hello,

    I want to create a square on a curve (in a loop), so I made a planefromframe and want to add some points for the square.
    With the vectorunitize and curvecurvature I want to creat the first point.
    Only the script gives a mismatch with the curvecurvature.

    I don't know where the problem is. I want to have the 4th element from the curvecurvature, but in the debug-mode, I get no input in crvcurve (curvecurvature), what Iam doing wrong?

    Option Explicit
    'Script written by <insert name>
    'Script copyrighted by <insert company name>
    'Script version woensdag 14 oktober 2009 11:59:57

    Call Main()
    Sub Main()

            Dim arrpoint1,arrpoint2,dblradius2,arrcone,arrplate
            Dim arrcurve,arrendpoint
            arrpoint1=Rhino.GetPoint ("pick bottom point")
            arrpoint2=Rhino.getpoint ("pick up point")
            arrcurve=Rhino.GetObject("pick curve for frame",4)
            Dim arrdomain,dblparam,crvpoint,crvtangent,crvperp
            Dim dblradiusx,crvnormal,crosssectionsplane,arrcircle
            '-----------------------------------------
            arrendpoint=Rhino.curveendpoint (arrcurve)
            Rhino.addpoint arrendpoint
            arrDomain = Rhino.CurveDomain(arrcurve)
            dblParam = arrDomain(1)
            crvpoint = Rhino.EvaluateCurve(arrcurve, dblParam)
            crvtangent=Rhino.CurveTangent(arrcurve,dblparam)
            crvperp=array(0,0,1)
            dblradiusx=0.35
            crvnormal=Rhino.VectorCrossProduct(crvtangent,crvperp)
            crosssectionsplane=Rhino.planefromframe(arrendpoint,crvperp,crvnormal)
            '---------------------------------------
            'temporary points
            Dim x0,x1,y0,y1,curvecrv,dblparamx,dblparamy
            dblparamy=Rhino.CurveClosestPoint (arrcurve, arrendpoint)
            curvecrv=Rhino.curvecurvature(arrcurve,dblparamy)
           
            Rhino.Print "  3-D Curvature: (" & Rhino.Pt2Str(curvecrv(4)) & ")"
            arrx= vectorunitize(curvecrv(4))
            x0=pointaddvector(arrendpoint,arrx)
           
           
            Dim arrtube
            arrtube=tube(arrpoint1,arrpoint2)
           
           

           
           
    End Sub


    Function tube(point1,point2)
            Dim dblradius1,dblradius2,arrbool,arrcopy
            Dim outercylinder,innercylinder,arrbool2
            Dim outercylinder2,innercylinder2,arrbool5
            dblradius1=0.96
            dblradius2=0.54
            outercylinder=Rhino.AddCylinder(point1,point2,dblradius1,True)
            innercylinder=Rhino.addcylinder(point1,point2,dblradius2,True)
            arrbool=Rhino.BooleanDifference(array(outercylinder),array(innercylinder),True)
           
    End Function

    Function intersection(obj1,obj2)
            Dim arrbool
            arrbool=Rhino.BooleanDifference (array(obj1), (obj2) , True)
           
    End Function
    Function pointaddvector(p,v)
            pointaddvector=Null
            If Not IsArray(p) Or (UBound(p)<>2) Then Exit Function
            If Not IsArray(v) Or (UBound(v)<>2) Then Exit Function
            pointaddvector=array(p(0)+v(0),p(1)+v(1),p(2),v(2))
           
    End Function
    Function vectorunitize(v)
            vectorunitize = Null
            If Not IsArray(v) Or (UBound(v)<>2) Then Exit Function
            Dim dist,x,y,z,x2,y2,z2
            x=v(0):v=v(1):z=v(2)
            x2=x*x:v2=v*v:z2=z*z
            dist=x2+y2+z2
            If (dist<0.0) Then Exit Function
            dist=Sqr(dist)
            x=x/dist
            y=y/dist
            z=z/dist
            vectorunitize=array(x,y,z)
    End Function
Recommend

Why are these buttons gray?