Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Assignment-5

Name: Aditya Ram

Reg No:20BCE7102

Question 1:

1. Write programs to implement basic 3D primitives: box, cube, sphere etc.

Code:

size(600,600,P3D);
//background(0);
translate(100,75,0);
sphere(50);
translate(150,150,0);
box(70);
translate(200,250,100);
rotateX(1);
noFill();
box(80);
Question 2:

2. Write a program to implement a 3D pyramid using vertex.

Code:
size(640, 640, P3D);
background(0);

translate(width/2, height/2, 0);


stroke(255);
rotateX(PI/2);
rotateZ(-PI/6);
noFill();

beginShape();
vertex(-100, -100, -100);
vertex( 100, -100, -100);
vertex( 0, 0, 100);

vertex( 100, -100, -100);


vertex( 100, 100, -100);
vertex( 0, 0, 100);

vertex( 100, 100, -100);


vertex(-100, 100, -100);
vertex( 0, 0, 100);

vertex(-100, 100, -100);


vertex(-100, -100, -100);
vertex( 0, 0, 100);
endShape();

Output:

You might also like