Forgot password?

Create an account!

Forum

« back

RhinoScript – Surface Normals and DotProduct

Messages

Please log in to write a message.

  • 3. deriva (Nov 25, 2013 17.11):

    Thanks Hanno for your help. I gave up. I switched to Grasshopper yesterday when i was stuck on this and in half day not only I have rewrote the whole script from scratch but I pushed it much further. I have my studio exam in less then ten days, the prof pushed us toward RS...but no time left to learn it now.

    thanks again,
    deriva

  • 2. Hanno (Nov 25, 2013 10.22):

    Hi deriva,

    one thing I noticed: You keep overwriting arrParam with different surface parameters, and still in the end you draw a vector from the first point you evaluated (topPts(0)). So the normal direction does not fit to the base point.

    And yes, the dot product between two normalized vectors will be between -1 and 1.

    Hanno

  • 1. deriva (Nov 24, 2013 17.45):

    Hello everyone,
    I am trying to panelize a surface with different panels accordingly to the dotproduct of the local normal vector compared to a given sunVector.

    problem #1: the normal vectors look wrong, I do not need to visualize them, I did just to check. I also tried different derivatives but still they don't look right.

    problem #2: I unitized the vector before the dotProduct so the result should vary between -1 and 1, right?

            ' Step along in U direction - numU
                    For i = 0 To (numU - 1)                
                               
                            ' Step along in V direction - numV
                            For j = 0 To (numV - 1)
     
                                    ' Set current layer
                                    Rhino.CurrentLayer "pointLayer"
           
                                    ' Top Point 1
                                    arrParam(0) = (i / numU) * topDomainU(1)
                                    arrParam(1) = (j / numV) * topDomainV(1)
                                    topPts(0) = Rhino.EvaluateSurface(topSurf, arrParam)
                                    Rhino.AddPoint topPts(0)
           
                                    ' Top Point 2
                                    arrParam(0) = ((i + 1) / numU) * topDomainU(1)
                                    arrParam(1) = (j / numV) * topDomainV(1)
                                    topPts(1) = Rhino.EvaluateSurface(topSurf, arrParam)
                                    If i = (numU - 1) Then Rhino.AddPoint topPts(1)

    '......more points here, then...

            ' Evaluate Surface normal                              
                                    srfEval = Rhino.SurfaceEvaluate(topSurf, arrParam, 0)
                                    vecNormal = Rhino.SurfaceNormal(topSurf, arrParam)
                                    Call DrawVector(topPts(0), vecNormal)
                                   
                                   
                                    ' Calculate angle between vectors
                                    vecNormalUnit = Rhino.VectorUnitize(vecNormal)
                                    vecSunUnit = Rhino.VectorUnitize(vecSun)
                                    dblDot = Rhino.VectorDotProduct(vecNormalUnit, vecSunUnit)
                                   
                                   
                                    'Rhino.Print(dblDot)
                                   
                                    If -0.5 < dblDot < 0.5 Then
                                           
                                            ' Draw Top panels
                                            Rhino.AddSrfPt Array(topPts(0), topPts(1), topPts(5), topPts(4))
                                            Rhino.AddSrfPt Array(topPts(1), topPts(2), topPts(6), topPts(5))
                                            Rhino.AddSrfPt Array(topPts(0), topPts(2), topPts(6), topPts(4))
                                            Rhino.AddSrfPt Array(topPts(0), topPts(2), topPts(3))

    '...more points here...that's it

    Any help in clarifying these issues would be highly appreciated.
    deriva

Recommend

Why are these buttons gray?