cadjs polygons and polyarcs
DESCRIPTION
Review Question Base: (50,50,2) Cylinder: r =5, h = 30 Hole: r = 2 Use one for-loop! Step 1 Step 2 Step 3 Step 4TRANSCRIPT
CADjs
Polygons and Polyarcs
Review Question
Base: (50,50,2)Cylinder: r =5, h = 30Hole: r = 2
Use one for-loop!
Step 1 Step 2 Step 3 Step 4
Review Question - Solution
base = cube(50,50,2);cyl1 = cylinder(5,30).rotateX(90).translateZ(15);cyl2 = cylinder(2,40).rotateX(90).translateZ(20);tube = cyl1.difference(cyl2).translate(20,20,0);
for (i = 0; i < 4;i++) { tube.rotateZ(90*i); base = base.union(tube);}base.display();
Wedge
How to create?
Subtract one cube from another!
Wedge
s=polygon([ [0,0],[1,0],[0,1] ]);s.display();
g = extrudeShape(s,0.25);//thicknessg.display();
(0,0)(1,0)
(1,0)
Star
s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);s.display();
(0,50)
(10,10)(50,10)
Star
s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);s.display();
g = extrudeShape(s,10);g.display();
Hollow Wedge
s=polygon([ [0,0],[1,0],[0,1] ]);h = polygon([ [0.1,0.1],[0.8,0.1], [0.1,0.8]]);s.holes.push(h);s.display();
g = extrudeShape(s,0.2);g.display();
Star with Hole
Star with Hole
s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);
star = extrudeShape(s,10);hole = cylinder(5,30).rotateX(90);
star = star.difference(hole);star.display();
Try …
100
20
10
R = 5
Engineering Drawings
More Examples
Method 1:Block + Cylinder
Method 2:Sketch and Extrude
2D Shape with Arcs
s = start2DGeom(0,0);s.addLine(1,0);s.addArc(1,1,1,0.5,false); //xEnd,yEnd,xCenter,yCenter,Clockwises.addLine(0,1);s.display();//display 2D shape
(0,0) (1,0)
(1,1)(0,1)
(1,0.5) Anti-clockwise
2D Shape with Arcs
s = start2DGeom(0,0);s.addLine(1,0).addLine(1,0.4).addLine(0.5,0.4);s.addArc(0.4,0.5,0.5,0.5,true); //xEnd,yEnd,xCenter,yCenter,Clockwises.addLine(0.4,1).addLine(0,1).addLine(0,0);s.display();//display 2D shape
(0,0)
(1,0)
(1,0.4)
(0.5,0.4)
(0.4,0.5)(0.5,0.5)
Clockwise
Example
Method 1
g= cube(60,20,38).translateZ(21);
g1 = cube(30,60,38).translateZ(49);
g2 = cylinder(30,20,100);
g3 = cylinder(15,50,39);
g = g.difference(g1).union(g2).difference(g3);
g.display();
Method 2
arc = [38,60,38,30,false];s=polyarc([[0,0],[38,0], arc,[0,60],[0,45],[10,45],[10,15],[0,15] ] );g = extrudeShape(s,20);cyl = cylinder(15,25).rotateX(90).translate(38,30,10);g = g.difference(cyl);g.display();
Method 3
arc = [38,60,38,30,false];s = polyarc([[0,0],[38,0], arc,[0,60],[0,45],[10,45],[10,15],[0,15] ] );c = circle(38,30,15);s.holes.push(c);g = extrudeShape(s,20);g.display();