'MAKING A BRIDGE FROM TWO CURVES '================================================================= 'You are responsible for creating a bridge using the curves below 'The points that create the curves can be manipulated for variance 'in bridge curvature '================================================================= 'Coded by 'Daniel Cardoso && Ricardo Dávila && Neri Oxman 'As an exercise for Kenfield Griffith and John Snavely's Computational Design Solutions I 'January 18, 2006 '************************************************************************************************* MAKE CURVES function makeCurves() 'This variation of the provided make curves function allows the user to select the two curves at the 'beginning and end of the bridge and to determine the number of subdivisions along the curves. dim crv1 dim crv2 dim ptNum1 dim ptNum2 crv1 = Rhino.getObject( "Get Object", 4 ) crv2 = Rhino.getObject( "Get Object", 4 ) 'Here we initialize the variables for the number of subdivisions along the mother curves with 'Default Values. ptNum1 = 10 ptNum2 = 20 'After initializaing them, here we ask the user to enter an integer to be stored as ptNum1 and 'ptNum2: the number of subdivisions along mother and child curves respectively. ptNum1 = Rhino.IntegerBox("Enter number of Subdivisions along mother curves: ", ptNum1 ) ptNum2 = Rhino.IntegerBox("Enter number of Subdivisions along mother curves: ", ptNum2 ) 'Use the built curves and the user input values for subdivisions to build the bridge call makeBridge(crv1, crv2, ptNum1, ptNum2) end function '************************************************************************************************* MAKE BRIDGE function makeBridge(crv1, crv2, ptNum1, ptNum2) 'ARGUMENTS 'crv1,crv2 are two given curves. We call them: "mother curves" 'ptNum1 and ptNum2 are the user input values that determine the number of subdivisions along the mother 'and child curves respectively 'VARIABLES 'ParamsC1 stores the Umin and Umax values of curve C1. 'ParamsC2 stores the Umin and Umax values of curve C2. dim ParamsC1 dim ParamsC2 'Pts1 stands for the actual points to be placed on curve C1. 'Pts2 stands for the actual points to be placed on curve C2. dim Pts1 dim Pts2 'i is the counter for the subdivision points ptNum1; j is the counter for the subdivision points ptNum2 dim i, j 'Uval is assigned the relative position of any given points (Pts1 and Pts2 respectively) along the curves (crv1 and crv2 respectivelly). 'It's actually the same as a Tvalue point in GC. dim Uval1 dim Uval2 dim mat( 100, 100 ) 'ACTIONS 'ParamsC1 and C2 store the two parameters of crv1 and crv2 respectively. 'These parameters are Umin and Umax. These variables are arrays. 'params(0) = Umin 'params(1) = Umax ParamsC1 = Rhino.curveDomain( crv1 ) ParamsC2 = Rhino.curveDomain( crv2 ) 'This is the important loop where we find the points along the curves, and create lines between them, generating a grid. for i = 0 to ptNum1 'Here we are finding the position of the next subdivision point along the two mother curves Uval1 = ( ( ParamsC1(1)-ParamsC1(0) ) / ( ptNum1 ) ) * ( i ) Uval2 = ( ( ParamsC2(1)-ParamsC2(0) ) / ( ptNum1 ) ) * ( i ) 'Here we are placing the points along the two mother curves. These points are relative points and thus use the same Uval. Pts1 = Rhino.EvaluateCurve( crv1, Uval1 ) Pts2 = Rhino.EvaluateCurve( crv2, Uval2 ) 'each line, as it is being created, is stored in "currentLine" dim currentLine: currentLine = Rhino.AddLine(Pts1,Pts2) 'Once this child curve is created, we're going to subdivide it, and 'and create lines between them, while subdividing them and storing them in a 2d array: for j=0 to ptNum2 'Here we find the parameters (Umin and Umax) of our current line dim paramsCurrentLine : paramsCurrentLine = Rhino.CurveDomain( currentLine ) 'Here we find the next subdivision point along the current line dim UvalCurrent : UvalCurrent = (( paramsCurrentLine(1) - paramsCurrentLine( 0 )) / ( ptNum2 )) * ( j ) 'And here we store that point in a 2d array mat( i, j ) = Rhino.EvaluateCurve(currentLine, UvalCurrent) next next 'this nested loop draws segments between the materix points: i for columns, and j for rows: for i=1 to ptNum1 for j=0 to ptNum2 call Rhino.AddLine(mat(i,j),mat(i-1,j)) next next 'Just checkin'! Rhino.Print crv1 Rhino.Print crv2 Rhino.Print ptNum1 Rhino.Print ptNum2 end function '************************************************************************************************* MAIN makeCurves