Created
June 2, 2017 17:24
-
-
Save juandjara/36a28ca1763b78ff3c32bdfbe9b47290 to your computer and use it in GitHub Desktop.
Examen practico MVG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%APELLIDOS, NOMBRE: Domínguez Jara, Juan | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%Ejercicio 1: | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% NOTA: Este codigo ha sido desarrollado con GNU Octvae | |
% para cualquier duda envie un email a [email protected] | |
clear; | |
marco(100,100,500,500,'white') | |
ventana(0.1,0.1,0.8,0.8,0,9,0,13,-1,1) | |
pol1_x = [0 2 2 0]; | |
pol1_y = [0 0 2 2]; | |
pol2_x = [0 2 1]; | |
pol2_y = [0 0 2]; | |
center1_x = mean(pol1_x); | |
center1_y = mean(pol1_y); | |
center1 = [center1_x; center1_y; 0; 1]; | |
center2_x = mean(pol2_x); | |
center2_y = mean(pol2_y); | |
center2 = [center2_x; center2_y; 0; 1]; | |
pol1 = [pol1_x; pol1_y; zeros(1, length(pol1_x)); ones(1, length(pol1_x))]; | |
pol2 = [pol2_x; pol2_y; zeros(1, length(pol2_x)); ones(1, length(pol2_x))]; | |
deg_to_rad = (2*pi)/360; | |
cuerpo = traslacion([1; 2; 0]) * escalado([7/2 6/2 0], [0;0;0]) * pol2; | |
cara = traslacion([3; 8; 0]) * escalado([3/2 3/2 0], [0;0;0]) * pol1; | |
sombrero = traslacion([2; 11; 0]) * escalado([5/2 0.75 0], [0;0;0]) * pol2; | |
boca = traslacion([3.75; 8.5; 0]) * escalado([0.75 0.125 0], [0;0;0]) * pol1; | |
brazo_izq = traslacion([2.8; 5.5; 0]) * rotacion(deg_to_rad * 60, [0;0;0], 'z') * escalado([0.5 0.75 0], [0;0;0]) * pol1; | |
brazo_der = traslacion([7.3; 6.5; 0]) * rotacion(deg_to_rad * 120, [0;0;0], 'z') * escalado([0.5 0.75 0], [0;0;0]) * pol1; | |
puntos_control_curva = [ | |
2 2 4 4; | |
2 1 1 2; | |
0 0 0 0; | |
1 1 1 1; | |
]; | |
curva = Bezier_cubica(puntos_control_curva); | |
curva_center = [ | |
mean(curva(1, :)); | |
mean(curva(2, :)); | |
0 | |
]; | |
pie = curva; | |
pie2 = traslacion([3; 0; 0]) * curva; | |
hold on; | |
%dibujarBezier(curva, [1 1 1], 5); | |
plot(pie(1, :), pie(2, :), 'color', 'black', 'lineWidth', 3); | |
plot(pie2(1, :), pie2(2, :), 'color', 'black', 'lineWidth', 3); | |
fill(cara(1, :), cara(2, :), [1 1 0.8]); | |
fill(cuerpo(1, :), cuerpo(2, :), 'red'); | |
fill(sombrero(1, :), sombrero(2, :), 'black'); | |
% ojo iziquierdo | |
plot(3.75, 10.25, '.', 'MarkerSize', 20, 'color', 'black'); | |
% ojo derecho | |
plot(5.25, 10.25, '.', 'MarkerSize', 20, 'color', 'black'); | |
fill(boca(1, :), boca(2, :), 'red'); | |
fill(brazo_izq(1, :), brazo_izq(2, :), 'black'); | |
fill(brazo_der(1, :), brazo_der(2, :), 'black'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%APELLIDOS, NOMBRE: Domínguez Jara, Juan | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%Ejercicio 2: | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% NOTA: Este codigo ha sido desarrollado con GNU Octvae | |
% para cualquier duda envie un email a [email protected] | |
Vert = [ | |
-2 -2 2 2 0 0; | |
2 -2 -2 2 0 0; | |
0 0 0 0 4 -4; | |
1 1 1 1 1 1 | |
]; | |
Caras = [ | |
1 2 5; | |
1 4 5; | |
3 4 5; | |
2 3 5; | |
1 2 6; | |
1 4 6; | |
3 4 6; | |
2 3 6; | |
]; | |
Color = [ | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
1 0 0; | |
]; | |
figure(1); | |
% dibujando el poliedro en 3D | |
% IMPORTANTE: Si se usa este codigo en GNU Octave | |
% comentar la linea "alpha(0.5);" de la funcion "dibujarEscena" | |
dibujarEscena(Vert, Caras, Color); | |
P = [1 1 5]; | |
Pm = [0 0 0]; | |
L = 2; | |
FOV = 100; | |
% vertices en sist de la camara | |
Cam = camara(P, Pm, L); | |
% matriz de proyeccion | |
Proy = [ | |
1 0 0 0; | |
0 1 0 0; | |
0 0 1 0; | |
0 0 0.5 0; | |
]; | |
% vertices proyectados | |
Vp = Proy * Cam * Vert; | |
dim = dimension_ventana(L, FOV); | |
figure(2); | |
% dibujando el poligono resultante | |
dibujarPerspectiva(Vp, dim, Caras, Color); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment