'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 '================================================================= '=======MAKECURVES FUNCTION======================================= 'This function creates two curves from points as paramaters 'the location of points can be manipulated for creating different 'bridge results '================================================================= function makeCurves() 'curves will be created from 4 points 'you are welcome to add more points for creating different 'types of curves, but the minimum should be 4 Dim crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4 'Define the variables for each point of curve one Dim crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4 'Define the variables for each point of curve two Dim crvOne, crvTwo 'Define variables for curves 'Create array of points crvOnePt1 = Array(0.0, -45.0, 10.0) 'create three floats that are the (X,Y,Z) values of the point crvOnePt2 = Array(10.0, -5.0, -15.0) crvOnePt3 = Array(0.0, 25.0, 50.0) crvOnePt4 = Array(0.0, 60.0, -1.0) crvTwoPt1 = Array(100.0, -50.0, -1.0) 'create three floats that are the (X,Y,Z) values of the point crvTwoPt2 = Array(150.0, -10.0, 15.0) crvTwoPt3 = Array(100.0, 15.0, 25.0) crvTwoPt4 = Array(100.0, 60.0, 10.0) crvOne = Rhino.AddInterpCurve(Array(crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4)) 'Create first curve with array of points crvTwo = Rhino.AddInterpCurve(Array(crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4)) 'Create second curve with array of points 'Use the built curves to build bridge call makeBridge(crvOne, crvTwo) end function '**************************************** '===== FUNCTION CODED BY NERI OXMAN, DANIEL CARDOSO, RICARDO DAVILA ========= '**************************************** '=======MAKEBRIDGE FUNCTION======================================= 'This function uses the two curves from above function to build 'your bridge '================================================================= 'In this function body you will be responsible for using the 'two curves c1 and c2 above which are passed as parameters 'to build your bridge 'you are allowed to use as many helper functions as necessary 'Concentrate on keeping your solution simple in the beginning 'you are welcome to elaborate on your design after you have something 'working function makeBridge(c1, c2) 'c1,c2 are two given curves. We call them: "mother curves" 'Declare variables dim ptNum1 dim ptNum2 'ptNum1 represents the number of points along the "mother" curves to indicate the number of subdivisions. 'ptNum2 represents the number of points along the "child" curves (perpendicular to the mother curves) to indicate the number of subdivisions. dim ParamsC1 dim ParamsC2 'ParamsC1 stores the Umin and Umax values of curve C1. 'ParamsC2 stores the Umin and Umax values of curve C2. dim Pts1 dim Pts2 '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 i 'i is the counter for the subdivision points ptNum1 dim j 'j is the counter for the subdivision points ptNum2 dim Uval1 dim Uval2 'Uval is assigned the relative position of any given points (Pts1 and Pts2 respectfully) along the BSpline curves (c1 and c2 respectfuly). It's actually the same as a Tvalue point in GC. ParamsC1=Rhino.curveDomain(c1) ParamsC2=Rhino.curveDomain(c2) 'params(0) = Umin 'params(1) = Umax ptNum1=10 '("Enter the number of subdividing points for the two given U curves of the bridge",4,20) ptNum2=20 '("Enter the number of subdividing points for the resulting V curves of the bridge",4,20) 'ask the user to define input data for subdivisions dim mat(10, 20) 'mat stands for the 2D array which will be created out of the suvdivision points of the mother and child curves. for i=0 to ptNum1 Uval1=((ParamsC1(1)-ParamsC1(0))/(ptNum1))*(i) Uval2=((ParamsC2(1)-ParamsC2(0))/(ptNum1))*(i) Pts1=Rhino.EvaluateCurve(c1,Uval1) Pts2=Rhino.EvaluateCurve(c2,Uval2) 'this process allows us to place points along the two mother curves. These points are relative points and thus use the same Uval. dim currentLine: currentLine = Rhino.AddLine(Pts1,Pts2) 'each line, as it is being created, is stored in "currentLine" for j=0 to ptNum2 dim paramsCurrentLine : paramsCurrentLine=Rhino.CurveDomain(currentLine) dim UvalCurrent : UvalCurrent = ((paramsCurrentLine(1)-paramsCurrentLine(0))/(ptNum2))*(j) mat(i,j) = Rhino.EvaluateCurve(currentLine,UvalCurrent) next next 'this nested loop (above) creates a matrix of points which are place on "mother lines" for i=1 to ptNum1 for j=0 to ptNum2 call Rhino.AddLine(mat(i,j),mat(i-1,j)) next next 'this nested loop draws segments between the materix points: i for columns, and j for rows end function makeCurves