Python Tutorials | (back to the list of tutorials) |
add_library('igeo') size(480, 360, IG.GL) cpts1 = [ IVec(-60,0,0),IVec(-40,0,0),IVec(-40,20,0),IVec(-60,20,0)] curve1 = ICurve(cpts1).clr(0) IG.offset(curve1, 5.0).clr(1.0,0,0) cpts2 = [ IVec(-20,0,0), IVec(-10,20,0), IVec(-10,0,0) ] curve2 = ICurve(cpts2, True).clr(0) IG.offset(curve2, 5).clr(1.0,0,0) cpts3 = [ IVec(10,0,0),IVec(20,20,0),IVec(20,0,0) ] curve3 = ICurve(cpts3, 2).clr(0) IG.offset(curve3, 5).clr(1.,0,0) cpts4 = [ IVec(40,0,0),IVec(50,20,0),IVec(50,0,0) ] curve4 = ICurve(cpts4, 2, True).clr(0) IG.offset(curve4, 5).clr(1.,0,0) cpts5 = [ IVec(-20,60,0),IVec(10,60,0),IVec(10,60,20) ] curve5 = ICurve(cpts5, True).clr(0) IG.offset(curve5, 5).clr(1.,0,0) cpts6 = [ IVec(80,0,0),IVec(90,0,20),IVec(100,0,20),IVec(100,20,20),IVec(80,20,0) ] curve6 = ICurve(cpts6, True).clr(0) IG.offset(curve6, 5).clr(1.,0,0)
The offset distance of degree 1 curve can have
constant distance between the original curve (polyline) and
the offset one, like the curve1 and curve2 in
the code above.
However, if the curve's degree is more than 2 and
curving, the distance between two curve is not constant,
like curve3 and curve4 on the code,
because it's simply taking offset vertices of a degree 1 curve
as its control points.
If an input curve is not planar curve,
offset curve is deformed accordingly and also non-planar, like
the curve6 on the code.
add_library('igeo') size(480, 360, IG.GL) cpts1 = [ IVec(-50,0,0),IVec(-30,0,0),IVec(-30,-20,0),IVec(-50,-20,0) ] curve1 = ICurve(cpts1).clr(1.,0,1.) cpts2 = [ IVec(-40,20,30),IVec(-30,20,30),IVec(-30,0,30),IVec(-40,0,30) ] curve2 = ICurve(cpts2).clr(1.,0,1.) # loft of two curves IG.loft(curve1, curve2).clr(0.2) cpts3 = [ IVec(-20,0,0),IVec(10,0,0),IVec(10,-20,0),IVec(-20,-20,0) ] curve3 = ICurve(cpts3,3,True).clr(1.,1.,0) cpts4 = [ IVec(-10,0,20),IVec(0,0,20),IVec(0,-20,20),IVec(-10,-20,20) ] curve4 = ICurve(cpts4,3,True).clr(1.,1.,0) cpts5 = [ IVec(-20,20,40),IVec(10,20,40),IVec(10,-20,40),IVec(-20,-20,40) ] curve5 = ICurve(cpts5,3,True).clr(1.,1.,0) # loft of multiple curves in an array (degre=1, straight) IG.loft([ curve3, curve4, curve5 ]).clr(0.2) curve6 = curve3.dup().mv(40,0,0).clr(0,1.,1) curve7 = curve4.dup().mv(40,0,0).clr(0,1.,1) curve8 = curve5.dup().mv(40,0,0).clr(0,1.,1) # degree 2 curved lofting IG.loft([ curve6, curve7, curve8 ], 2 ).clr(0.2)
add_library('igeo') size(480, 360, IG.GL) pts1 = [ IVec(-50,-20,0),IVec(-30,-20,0),IVec(-30,0,0),IVec(-50,0,0) ] # extrude points to their normal direction IG.extrude(pts1, 30).clr(0.2) pts2= [ IVec(-20,0,0),IVec(10,0,0),IVec(10,-20,0),IVec(-20,-20,0) ] # extrude degree 2 closed profile IG.extrude(pts2, 2, True, -20).clr(0.2) pts3= [ IVec(20,0,0),IVec(50,0,0),IVec(50,-20,0),IVec(20,-20,0) ] # extrude in the direction specified by a vector IG.extrude(pts3, 1, True, IVec(10,20,30)).clr(0.2)
add_library('igeo') size(480, 360, IG.GL) pts1 = [ IVec(-50,-20,0),IVec(-30,-20,0),IVec(-30,0,0),IVec(-50,0,0) ] curve1 = ICurve(pts1).clr(1.,0,1.) IG.extrude(curve1, 30).clr(0.2) pts2 = [ IVec(-20,0,0),IVec(10,0,0),IVec(10,-20,0),IVec(-20,-20,0) ] curve2 = ICurve(pts2, 2, True).clr(1.,1.,0) IG.extrude(curve2, -20).clr(0.2) pts3 = [ IVec(20,0,0),IVec(50,0,0),IVec(50,-20,0),IVec(20,-20,0) ] curve3 = ICurve(pts3, 1, True).clr(0,1.,1.) IG.extrude(curve3, IVec(10,20,30)).clr(0.2)
add_library('igeo') size(480, 360, IG.GL) profile1 = [ IVec(5,0,0),IVec(5,5,0),IVec(0,5,0) ] rail1 = [ IVec(-40,0,-20),IVec(-30,0,10),IVec(-50,0,20) ] # sweeping open profile and open rail IG.sweep(profile1, rail1).clr(0.2) profile2 = [ IVec(0,0,0),IVec(10,0,0),IVec(10,10,0),IVec(0,10,0) ] rail2 = [ IVec(0,20,-20),IVec(0,0,20),IVec(0,-20,-20) ] # sweeping degree 2 closed profile and degree 2 open rail IG.sweep(profile2, 3, True, rail2, 2, False).clr(0.5,0,0) profile3 = [ IVec(-5,0,0),IVec(0,5,0),IVec(0,-5,0) ] rail3 = [ IVec(40,20,-20),IVec(40,0,20),IVec(40,-20,-20) ] # sweeping degree 2 closed profile and degree 2 open rail IG.sweep(profile3, 1, True, rail3, 1, True).clr(0,0,0.5)
add_library('igeo') size(480, 360, IG.GL) profile1 = [ IVec(0,0,0),IVec(10,0,0),IVec(10,10,0),IVec(0,10,0) ] profileCrv1 = ICurve(profile1,3).clr(0,1.,1.) rail1 = [ IVec(-50,0,-30),IVec(-30,0,0),IVec(-30,0,30) ] railCrv1 = ICurve(rail1).clr(1.,1.,0) # sweeping open profile and open rail IG.sweep(profileCrv1, railCrv1).clr(0.2) # ellipse profile profileCrv2 = ICircle(0,0,0,10,5).clr(0,1.,1.) rail2 = [ IVec(0,20,-20),IVec(0,0,20),IVec(0,-20,-20) ] railCrv2 = ICurve(rail2, 2).clr(1.,1.,0) # sweeping degree 2 closed profile and degree 2 open rail IG.sweep(profileCrv2, railCrv2).clr(0.5,0,0) profile3 = [ IVec(-5,0,0),IVec(0,5,0),IVec(0,-5,0) ] profileCrv3 = ICurve(profile3,True).clr(0,1.,1.) # circle profile railCrv3 = ICircle(IVec(40,0,0),IVec(1,0,0),30).clr(1.,1.,0) # sweeping degree 2 closed profile and degree 2 open rail IG.sweep(profileCrv3, railCrv3).clr(0,0,0.5)
add_library('igeo') size(480, 360, IG.GL) curve1 = ICurve(IVec(-40,0,-20),IVec(-30,20,30)) IG.pipe(curve1, 2).clr(.2) curve2 = ICurve([ IVec(-10,0,-30),IVec(-10,-10,-10),IVec(-10,10,10),IVec(-10,0,30) ]) IG.pipe(curve2,6).clr(0.5,0,0) curve3 = ICircle(IVec(20,0,0),IVec(1,0,0),20) IG.pipe(curve3,4).clr(1.0,0,0.5) curve4 = ICurve([ IVec(50, -20, 20),IVec(40, 30, 0),IVec(70, 0, 40), \ IVec(50, -10, -10),IVec(60, -40, -10) ], \ 2, True) IG.pipe(curve4, 4).clr(0,0,0.8)
In the same way with creating circular pipes, you can also create rectangular or square pipes with IG.rectPipe(ICurve,double,double) or IG.squarePipe(ICurve,double).
add_library('igeo') size(480, 360, IG.GL) curve1 = ICurve(IVec(-40,0,-20),IVec(-30,20,30)) IG.rectPipe(curve1, 10,2).clr(.2) curve2 = ICurve([ IVec(-10,0,-30),IVec(-10,-10,-10),IVec(-10,10,10),IVec(-10,0,30) ]) IG.rectPipe(curve2,5,10).clr(0.5,0,0) curve3 = ICircle(IVec(20,0,0),IVec(1,0,0),20) IG.squarePipe(curve3,8).clr(1.0,0,0.5) curve4 = ICurve([ IVec(50, -20, 20),IVec(40, 30, 0),IVec(70, 0, 40), \ IVec(50, -10, -10),IVec(60, -40, -10) ], \ 2, True) IG.squarePipe(curve4,8).clr(0,0,0.8)