top of page

Computer Graphics Exercises (For Practice)

  • Karla G
  • 28 mar 2015
  • 2 Min. de lectura

Your aswers to the questions must be at least approximated to real answers.

Questions:

1.- Draw a sphere of large 20 and make it rotate over its own axis.

2.- Draw a letter "E" .

3.- Draw a box(10); //of size 10*10 Now, using scale, convert it to a prism, with 40 of height, and a squared base of 10*10.

Answers:

1.-

float x=0;

void setup(){

size(500,500,P3D);

float fov = PI/3.0;

float cameraZ = (height/2.0) / tan(fov/2.0);

perspective(fov, float(width)/float(height), cameraZ/100.0, cameraZ*10.0);

}

void draw(){

background(0,0,0);

camera(50*mouseX/500.0, -50*mouseY/500.0,40, 0,0,0, 0,1,0);

x=x+1;

noFill();

stroke(255);

rotate(sin(x));

sphere(10);

}

2.-

float x;

void setup(){

size(500,500,P3D);

float fov = PI/3.0;

float cameraZ = (height/2.0) / tan(fov/2.0);

perspective(fov, float(width)/float(height), cameraZ/100.0, cameraZ*10.0);

}

void draw (){

background(0,0,0);

camera(50*mouseX/500.0, -50*mouseY/500.0,40, 0,0,0, 0,1,0);

strokeWeight(5);

stroke(255,0,0); //red

line(0,0,0, 10,0,0); //x axis

stroke(0,255,0); //green color

line(0,0,0, 0,-10,0); //Y axis

stroke(0,0,255);

line(0,0,0, 0,0,10);//Z

noFill();

stroke(255,255,255);

beginShape(TRIANGLES);

vertex(0,-10,0);

vertex(6,-10,0);

vertex(2,-8,0);

vertex(2,-8,0);

vertex(6,-10,0);

vertex(6,-8,0);

vertex(0,-10,0);

vertex(2,-8,0);

vertex(0,0,0);

vertex(2,-6,0);

vertex(4,-6,0);

vertex(4,-4,0);

vertex(2,-6,0);

vertex(2,-4,0);

vertex(4,-4,0);

vertex(0,0,0);

vertex(2,-8,0);

vertex(2,-2,0);

vertex(0,0,0);

vertex(2,-2,0);

vertex(6,0,0);

vertex(2,-2,0);

vertex(6,-2,0);

vertex(6,0,0);

vertex(0,-10,10);

vertex(6,-10,10);

vertex(2,-8,10);

vertex(2,-8,10);

vertex(6,-10,10);

vertex(6,-8,10);

vertex(0,-10,10);

vertex(2,-8,10);

vertex(0,0,10);

vertex(2,-6,10);

vertex(4,-6,10);

vertex(4,-4,10);

vertex(2,-6,10);

vertex(2,-4,10);

vertex(4,-4,10);

vertex(0,0,10);

vertex(2,-8,10);

vertex(2,-2,10);

vertex(0,0,10);

vertex(2,-2,10);

vertex(6,0,10);

vertex(2,-2,10);

vertex(6,-2,10);

vertex(6,0,10);

vertex(0,0,0);

vertex(0,0,10);

vertex(6,0,10);

vertex(0,0,0);

vertex(6,0,0);

vertex(6,0,10);

vertex(0,-10,0);

vertex(0,-10,10);

vertex(6,-10,10);

vertex(0,-10,0);

vertex(6,-10,0);

vertex(6,-10,10);

vertex(0,-10,0);

vertex(0,0,10);

vertex(0,-10,10);

vertex(6,0,0);

vertex(6,-2,0);

vertex(6,0,10);

vertex(6,-2,10);

vertex(6,-2,0);

vertex(6,0,10);

vertex(2,-2,0);

vertex(2,-2,10);

vertex(6,-2,0);

vertex(6,-2,10);

vertex(2,-2,10);

vertex(6,-2,0);

vertex(2,-8,0);

vertex(2,-8,10);

vertex(6,-8,0);

vertex(6,-8,10);

vertex(2,-8,10);

vertex(6,-8,0);

vertex(2,-2,0);

vertex(2,-4,0);

vertex(2,-2,10);

vertex(2,-2,10);

vertex(2,-4,10);

vertex(2,-4,0);

vertex(2,-6,0);

vertex(2,-8,0);

vertex(2,-6,10);

vertex(2,-6,10);

vertex(2,-8,10);

vertex(2,-8,0);

vertex(4,-4,0);

vertex(4,-6,0);

vertex(4,-4,10);

vertex(4,-4,10);

vertex(4,-6,10);

vertex(4,-6,0);

endShape();

}

Captura de pantalla 2015-03-27 a las 22.28.19.png

Captura de pantalla 2015-03-27 a las 22.28.32.png

Captura de pantalla 2015-03-27 a las 22.28.50.png

3.-

void setup(){

size(500,500,P3D);

float fov = PI/3.0;

float cameraZ = (height/2.0) / tan(fov/2.0);

perspective(fov, float(width)/float(height), cameraZ/100.0, cameraZ*10.0);

}

void draw(){

background(0,0,0);

camera(50*mouseX/500.0, -50*mouseY/500.0,40, 0,0,0, 0,1,0);

noFill();

stroke(255);

scale(1,4);

box(10);

}

 
 
 

Comentarios


 THE ARTIFACT MANIFAST: 

 

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

 UPCOMING EVENTS: 

 

10/31/23:  Scandinavian Art Show

 

11/6/23:  Video Art Around The World

 

11/29/23:  Lecture: History of Art

 

12/1/23:  Installations 2023 Indie Film Festival

 FOLLOW THE ARTIFACT: 
  • Facebook B&W
  • Twitter B&W
  • Instagram B&W
 RECENT POSTS: 
 SEARCH BY TAGS: 

© 2023 by Karla Lugo. Proudly created with Wix.com

bottom of page