0% found this document useful (0 votes)
3 views3 pages

Lec_02_CADjs

The document outlines various 3D modeling techniques using CADjs, including creating and manipulating geometric shapes like cubes and spheres, applying transformations such as translation and rotation, and performing boolean operations like union and difference. It also covers advanced modeling techniques like mirroring and rounding corners of shapes. The document provides code snippets demonstrating these concepts and their visual outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Lec_02_CADjs

The document outlines various 3D modeling techniques using CADjs, including creating and manipulating geometric shapes like cubes and spheres, applying transformations such as translation and rotation, and performing boolean operations like union and difference. It also covers advanced modeling techniques like mirroring and rounding corners of shapes. The document provides code snippets demonstrating these concepts and their visual outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CADjs Primitives/Booleans/Transformations Lecture #2

g = cube(100,20,40);
g1 = sphere(30);
//g2 = g.union(g1);
//g.displayTransparent();
//g1.displayTransparent();
//g2.displayTransparent();

g.display();
g1.display();

//g2.display();

Translate/Rotate order of operations (Right hand rule)


g = cube(1,0.25,0.50);
g1 = g.clone();// create copy

g1.rotateX(60);
//g1.rotateY(30);

g1.translateY(0.5);
//g1.translateZ(2);
//g1.translateX(1);

g.display('red');
g1.display('blue');

Concatenation

g1 = cube(1,0.2,0.4);
g1.rotateX(90);
g1.translateY(0.5);
g = cube(0.2,1,0.5);
g=g.union(g1);

//g1 = cube(1,0.2,0.4).rotateX(90).translateY(0.5);
//g = cube(0.2,1,0.5).union(g1);

g.display();
Boolean subtract

g1 = cube(100,100,12.5);
g2 = cube(75,75,25).translate(25,25,0);
g3= g1.difference(g2);
//g1.display();
//g2.display();
g3.display();// Press F5 to see result

Note: The subtracted geometry does not need to be the exact size/shape of the material you
want to remove.

Mirror Transformation

g1 = cube(100,100,12.5);
g2 = cube(75,75,25).translate(25,25,0);
g3= g1.difference(g2);
//g1.display();
//g2.display();
g3.display();// Press F5 to see result
g4 = g3.clone();
g4 = g4.mirrorX();//change to Y and Z and observe results
g4.displayTransparent();

Simple solid block

a = cube(1,1,0.25);
a.display();

Parametric solid block

w = 1;
h = 0.25;
a = cube(w,w,h);
a.display();
Parametric modeling (add a fillet to one corner)

w = 1;
h = 0.25;
r = 0.1;// radius of rounded corner
a = cube(w,w,h);
c = cube(r,r,h).translate( w/2-r/2,w/2-r/2,0);
d = cylinder(r,h).rotateX(90).translate(w/2-r,w/2-r,0);
b = c.difference(d);
a = a.difference(b);
//d.display();
//c.display();
//b.display();
a.display();

Round all four corners

w = 1;
h = 0.25;
r = 0.1;
a = cube(w,w,h);
c = cube(r,r,h).translate( w/2-r/2,w/2-r/2,0);
d = cylinder(r,h).rotateX(90).translate(w/2-r,w/2-r,0);
b = c.difference(d);
b1 = b.clone().rotateZ(90);
b2 = b.clone().rotateZ(180);
b3 = b.clone().rotateZ(270);
a = a.difference(b).difference(b1).difference(b2).difference(b3);
a.display()

You might also like