Presentation is loading. Please wait.

Presentation is loading. Please wait.

CADjs Transformations

Similar presentations


Presentation on theme: "CADjs Transformations"— Presentation transcript:

1 CADjs Transformations
In this lecture, we will learn different types of transformations (translations, rotations, mirror and scaling)

2 Axis The most important concept you need to understand here is that of the coordinate axis. Your translations and rotations will be with respect to one or the other axis.

3 Question In which two directions did the cube move?
Consider this simple example. We can create a cube at the origin (top left) g = cube(1); g.display(); Suppose we want to move it to a different location (as in bottom left). How do we do that?

4 Translate Move a Cube in 3D space g = cube(1); g.translate(-1,0,1);
g.display(); We use the translate command. We are moving -1 unit in x and +1 unit in z, and nothing in y. You can also have translateX(-1) if you only need a translate in X, and so on

5 Rotate Rotates Cube in 3D space g = cube(1); g.rotateZ(45);
g.display(); Next, consider rotation. Here we take a cube and rotate about z axis by 45 degrees.

6 Rotation About X and Y Axis
g = cube(1); g.rotateX(45); g.display(); Now trying rotating about X and Y axis. Are you seeing what you expect? Try playing around with these numbers g = cube(1); g.rotateY(45); g.display();

7 Combining Transformations
g = cube(1); g.translateX(2); g.rotateZ(45); g.display(); You can now combine translations and rotations

8 Order of Transformations Matters
g = cube(1); g.translateX(2); g.rotateZ(45); g.display(); First Translate Then Rotate You can now combine translations and rotations g = cube(1); g.rotateZ(45); g.translateX(2); g.display(); First Rotate Then Translate

9 Question Now let us see how we can make this dog bone.
What primitives do we need? Answer: 1 cylinder and 2 spheres.

10 Answer g1=sphere(1); g2=sphere(1); g3=cylinder(.5,6);
g1.translate(0,3,0); g2.translate(0,-3,0); g3=g3.union(g1); g3=g3.union(g2); g3.display(); Walk through each line of the code, explaining what it does

11 More Questions (1) (2) (3) (4) Try the following exercises.
First find what primitives you need Next, move these to the right location Finally do the booleans Volunteers can go around the room helping the students (3) (4)

12 Answers 4) g1 = cylinder(1,3); g2=cylinder(.8,3); g2.translate(0,1,0);
1) g1 = cylinder(1,5); g2=cylinder(.9,5); g2.rotateZ(90); g=g1.union(g2); g.display(); 3) g1 = cylinder(1,3); g2=cylinder(.8,3); g2.translate(0,0,1); g=g1.difference(g2); 2) g1 = cylinder(1,5); g2=cylinder(.9,5); g2.rotateZ(90); g=g1.difference(g2); g.display(); 4) g1 = cylinder(1,3); g2=cylinder(.8,3); g2.translate(0,1,0); Solutions to the previous problems

13 Mini Project How many primitives do you need? Answer: 4

14 Code g= cube(60,20,38).translateZ(21);
g2 = cylinder(30,20,100); g3 = cylinder(15,50,39); g = g.difference(g1).union(g2).difference(g3); g.display(); Walk through the code, explaining each step.


Download ppt "CADjs Transformations"

Similar presentations


Ads by Google