Forgot password?

Create an account!


« back

RhinoScript – vector vector vector


Please log in to write a message.

  • 3. clausneergaard (Dec 14, 2010 23.09):


    thanks man. that actually makes sense. i got to remember that, it keeps confusing me.



  • 2. Hanno (Dec 14, 2010 09.35):


    i'm not sure I get your question. Is it the vector direction? This is simply a definition issue:

    Rhino.VectorCreate(arrPt2, arrPt1)

    gives you a vector from Pt1 to Pt2. This can be a bit confusing, I reckon it is because the vector from Pt1 to Pt2 can be written as P2 - P1, so VectorCreate might be simply an alias for VectorSubtract.



  • 1. clausneergaard (Dec 13, 2010 22.58):

    so, I'm having a hard time understanding this vector-stuff. in the very basic example below, I insert two random points, create a vector between the two, and then try to move pt1 closer to pt2. wouldn't it make sense that to create a vector from pt1 to pt2, scale the vector and then move pt1 based on new vector? apparently, to get it to work, the vector has to be created from pt2 to pt1?

    maybe I'm completely misunderstanding what it is all about.

    Option Explicit

    Call ScriptName()
    Sub ScriptName()

            '' insert two randomly located points
            Dim strPt1, strPt2
            Dim arrPt1, arrPt2
            strPt1 = Rhino.AddPoint(Array(Rnd*50,Rnd*50,0))
            arrPt1 = Rhino.PointCoordinates(strPt1)
            Rhino.AddTextDot "1", arrPt1
            strPt2 = Rhino.AddPoint(Array(Rnd*50,Rnd*50,0))
            arrPt2 = Rhino.PointCoordinates(strPt2)
            Rhino.AddTextDot "2", arrPt2
            '' create vector between poins
            Dim vec
            vec = Rhino.VectorCreate(arrPt2, arrPt1)  
            vec = Rhino.VectorScale(vec, 0.25)
            ' copy object based using the new vector
            Rhino.CopyObject strPt1, vec

    End Sub

Why are these buttons gray?