Forgot password?

Create an account!


« back

RhinoScript – domain split


Please log in to write a message.

  • 7. tm1 (Nov 30, 2010 15.36):

    hi hanno,

    good explanation. thanks for that. so far, i thought domain equals out the differences in the curve or control pt layout - something like percentage calculation. good to know it is not like this. means domain params of one curve can't be used for another curve unless they are reparameterized.


  • 6. Hanno (Nov 30, 2010 13.12):


    as I said: the parameter space is related to the control points. This means on the other hand, equal distances in parameter space are not necessarily equal distances in 3d space. When control points are moved away from each other, the parameter space will also be "stretched" in this part of the curve, and vice versa.

    The rebuild command rebuilds a curve with equally spaced control points. This is why in this case parameter space and 3d space correspond.


  • 5. tm1 (Nov 30, 2010 12.20):

    hi hanno, hi johannes,

    thank you very much -both of you! i appreciate your fast response!
    domain is a relative value - that's what i'm strugglling with. I understand when we talk about min and max. What I don't get: max/2 is different according to the control pts. when a curve length is set to 1, why is the center pt varying?

    When you run my script and switch of the rebuild curve in line 28, you can see what i mean. I offset a curve, divide it and and use the same division params on an unrolled curve with the same length as the offset curve. it doesn't work properly without the rebuild command.

    Call Main()
    Sub Main()

    Dim strCrv, strLine, strOffsetCrv, arrOffsetCrv
    Dim strObject, dblLength, arrPoints, arrPoint
    Dim arrCrv_Pt, arrOffCrv_Pt, arrParam_OffCrv_Pt, arrUniParam_OffCrv
    Dim dblOffsetCrvLength, dblSegmentLength, strSegmentLine
    Dim arrSeg_Pt_Eva
    Dim DomainCrv, DomainOffsetCrv, DomainLine, DomainPt
    Dim arrOffCrv_Pt_Eva, arrOffCrv_Pt_Eva_Uni
    Dim arrParam_Line_Pt, arrLine_Pt, arrLine_Pt_Eva

    strCrv = Rhino.GetObject("Select a curve",4)

    Rhino.OffsetCurve strCrv,Array(0,0,0),6

    strOffsetCrv = Rhino.GetObject("Select the Offsetcurve",4)

    Rhino.RebuildCurve strOffsetCrv, 3, 100

    dblOffsetCrvLength = Rhino.CurveLength(strOffsetCrv)

    strSegmentLine = Rhino.AddLine(array(0,0,0),array(dblOffsetCrvLength,0,0))

    If Rhino.IsCurve(strOffsetCrv) Then
    DomainCrv = Rhino.CurveDomain(strCrv)
    DomainOffsetCrv = Rhino.CurveDomain(strOffsetCrv)
    DomainLine = Rhino.CurveDomain(strSegmentLine)

    End If

    dblLength = 20

    arrPoints = Rhino.DivideCurveLength(strCrv, dblLength, True, True)

    For Each arrCrv_Pt In arrPoints

    arrOffCrv_Pt = Rhino.CurveClosestPoint(strOffsetCrv, arrCrv_Pt)

    'absolute Position
    arrOffCrv_Pt_Eva = Rhino.EvaluateCurve(strOffsetCrv,arrOffCrv_Pt)

    Rhino.AddPoint (arrOffCrv_Pt_Eva)
    'Subdivision curves
    Rhino.AddLine arrCrv_Pt,arrOffCrv_Pt_Eva

    'relative Position Domain > Unify OffCrv = 1

    DomainPt = arrOffCrv_Pt * DomainLine(1)/DomainOffsetCrv(1)

    Rhino.AddPoint array( DomainPt,0,0)

    End Sub

  • 4. Hanno (Nov 30, 2010 11.50):

    Hi tm1,

    Johannes != Hanno, there is more than one person active in this forum...

    the parameter space of a curve is always related to its control points. In your example, when you move the inner control points around, you also move the center of your parameter space around. The control points define the function that defines the curve, while the domain defines the possible input values.
    As Johannes already pointed out, the domain of a curve is a relative value, so its absolute magnitude does not matter. Reparameterize should not change the curve's control points, just normalize the input range.

    If you want to get segments of equal length, have a look at the different rhinoscript posibilities: CurveDivide, CurveDivideLength, CurveDivideEquidistant


  • 3. tm1 (Nov 30, 2010 11.35):

    hi hanno,

    thanks, it works. i wounder why curves that already have a domMin=0 and domMax=1 also change? is the command script available somewhere? it seems to rebuild the curve - is this the answer to question 2. maybe?
    i used rebuild curve to work around this problem and it worked too, but i think your approach is better.


  • 2. Johannes (Nov 30, 2010 08.49):


    the CurveDomain() method will return an array of two doubles which indicate the minimum and maximum t-parameters which lie on the curve. the start and end value depends on how you create the curve and on the curve degree.
    Normally the minimum is 0 and maximimum 1.... but try to create a curve with a script with more then 5 controlpoints... you will get values from -233 to 451...

    but you can reparameterize your curves that they all start with 0 and end with 1.

            Dim strCrv      : strCrv = Rhino.GetObject("pick a crv", 4)
            Dim CrvDom
            crvDom = Rhino.CurveDomain(strCrv)
            Call MsgBox("minimum: " & CrvDom(0) & ",  maximum: " & CrvDom(1))
            Call Rhino.UnselectAllObjects()
            Call Rhino.SelectObject(strCrv)
            Call Rhino.Command("-Reparameterize 0 1 ")
            Call Rhino.UnselectAllObjects() 
            crvDom = Rhino.CurveDomain(strCrv)
            Call MsgBox("minimum: " & CrvDom(0) & ",  maximum: " & CrvDom(1))
  • 1. tm1 (Nov 30, 2010 00.03):

    hi hanno,

    may be you can help me with a rather simple problem of understanding. I had problems of splitting a curve into similar segments to unroll them separatly. I found out the domain is somehow depending on the control point position. Two questions. please, take a look to the screenshot:
    1. the two lowest curves are similar both deg 1 - but one domain is 1 the other 100. Why that?
    2. The upper three curves are all deg 3 but their four control pts are on different positions. The script then places the center pt (domain(1)*0.5) on different positions. Why that?

    regards, till


Why are these buttons gray?