Perspectiva en coordenadas homogéneas

20
Perspectiva en coordenadas homogéneas José Luis Gómez-Muñoz http://homepage.cem.itesm.mx/jose.luis.gomez Sombra con perspectiva en dos dimensiones de un cubo tridimensional ü Generamos las coordenadas de los vértices del cubo unitario con el comando Tuples In[1]:= tuplas3D = Tuples@81, 1<,3D Out[1]= 881, 1, 1<, 81, 1, 1<, 81, 1, 1<, 81, 1, 1<, 81, 1, 1<, 81, 1, 1<, 81, 1, 1<, 81, 1, 1<< ü Obtenemos el número de coordenadas con el comando Length In[2]:= numcoords3D = Length@tuplas3DD Out[2]= 8 Printed by Wolfram Mathematica Student Edition

Transcript of Perspectiva en coordenadas homogéneas

Page 1: Perspectiva en coordenadas homogéneas

Perspectiva en coordenadas homogéneasJosé Luis Gómez-Muñoz

http://homepage.cem.itesm.mx/jose.luis.gomez

Sombra con perspectiva en dos dimensiones de un cubo tridimensional

ü Generamos las coordenadas de los vértices del cubo unitario con el comando Tuples

In[1]:=

tuplas3D = Tuples@8−1, 1<, 3DOut[1]= 88−1, −1, −1<, 8−1, −1, 1<, 8−1, 1, −1<,

8−1, 1, 1<, 81, −1, −1<, 81, −1, 1<, 81, 1, −1<, 81, 1, 1<<

ü Obtenemos el número de coordenadas con el comando Length

In[2]:=

numcoords3D = Length@tuplas3DDOut[2]=

8

Printed by Wolfram Mathematica Student Edition

Page 2: Perspectiva en coordenadas homogéneas

ü Dibujamos una esfera con centro en cada coordenada

In[3]:=

esferas3D = Table@8Hue@k ê numcoords3DD, Sphere@k, 0.1D<, 8k, numcoords3D<D;Graphics3D@GraphicsComplex@tuplas3D, 8esferas3D< D, Axes → TrueD

Out[4]=

2 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 3: Perspectiva en coordenadas homogéneas

ü Las aristas del cubo unitario se dibujan como tubos. Primero se crean “conexiones” entre todas

las coordenadas, pero después seleccionamos sólo aquellas conexiones con una longitud

exactamente de 2 unidades, esas son las aristas de este cubo:

In[5]:=

todoslospares3D = Subsets@Range@numcoords3DD, 82<D;numpares3D = Length@todoslospares3DD;paresconectados3D =

Select@todoslospares3D,

Function@8par<, Norm@tuplas3D@@ par@@1DD DD − tuplas3D@@ par@@2DD DDD � 2DD;

numconectados3D = Length@paresconectados3DD;tubos3D = Table@8Hue@k ê numpares3DD, Tube@Part@paresconectados3D, kD, 0.05D<,

8k, numconectados3D<D;Graphics3D@GraphicsComplex@tuplas3D, tubos3D D,Axes → TrueD

Out[10]=

ü Convertimos las coordenadas (x,y,z) en coordenadas homogéneas (x,y,z,1)

In[11]:=

coords3Dhomogeneas = Table@Join@Part@tuplas3D, kD, 81<D, 8k, numcoords3D<DOut[11]= 88−1, −1, −1, 1<, 8−1, −1, 1, 1<, 8−1, 1, −1, 1<, 8−1, 1, 1, 1<,

81, −1, −1, 1<, 81, −1, 1, 1<, 81, 1, −1, 1<, 81, 1, 1, 1<<

LAD0450perspectiva.nb 3

Printed by Wolfram Mathematica Student Edition

Page 4: Perspectiva en coordenadas homogéneas

ü Se aplica una matriz que corresponde a una traslación hacia “arriba”, en la dirección de la tercera

coordenada z:

In[12]:=

coords3Dhomogmovidas =

TableB1 0 0 0

0 1 0 0

0 0 1 2.4

0 0 0 1

.Part@coords3Dhomogeneas, kD, 8k, numcoords3D<F

Out[12]= 88−1., −1., 1.4, 1.<, 8−1., −1., 3.4, 1.<, 8−1., 1., 1.4, 1.<, 8−1., 1., 3.4, 1.<,81., −1., 1.4, 1.<, 81., −1., 3.4, 1.<, 81., 1., 1.4, 1.<, 81., 1., 3.4, 1.<<

ü Se aplica una matriz que corresponde a una proyección con perspectiva en el plano z=1

In[13]:=

coords3Dhomogperspectiva =

TableB1 0 0 0

0 1 0 0

0 0 1 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD, 8k, numcoords3D<F

Out[13]= 88−1., −1., 1.4, 1.4<, 8−1., −1., 3.4, 3.4<,8−1., 1., 1.4, 1.4<, 8−1., 1., 3.4, 3.4<, 81., −1., 1.4, 1.4<,81., −1., 3.4, 3.4<, 81., 1., 1.4, 1.4<, 81., 1., 3.4, 3.4<<

ü Se “renormalizan” las coordenadas para que la cuarta coordenada sea 1, es decir, (x,y,z,1)

In[14]:=

coords3Dnormalizadas =

TableB Part@coords3Dhomogperspectiva, kDPart@coords3Dhomogperspectiva, k, 4D , 8k, numcoords3D<F

Out[14]= 88−0.714286, −0.714286, 1., 1.<, 8−0.294118, −0.294118, 1., 1.<,8−0.714286, 0.714286, 1., 1.<, 8−0.294118, 0.294118, 1., 1.<,80.714286, −0.714286, 1., 1.<, 80.294118, −0.294118, 1., 1.<,80.714286, 0.714286, 1., 1.<, 80.294118, 0.294118, 1., 1.<<

4 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 5: Perspectiva en coordenadas homogéneas

ü Se regresa de la representación homogénea (x,y,z,1) a la tridimensional (x,y,z) y se grafica el cubo

y su proyección con perspectiva

In[15]:=

coords3Dmovidas =

TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD, 8k, numcoords3D<F;

coords3Dperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dnormalizadas, kD,

8k, numcoords3D<F;Graphics3D@8GraphicsComplex@coords3Dmovidas, 8tubos3D, esferas3D< D,GraphicsComplex@coords3Dperspectiva, 8tubos3D, esferas3D< D

<,Axes → TrueD

Out[17]=

LAD0450perspectiva.nb 5

Printed by Wolfram Mathematica Student Edition

Page 6: Perspectiva en coordenadas homogéneas

ü La siguiente animación muestra juntos al cubo rotando y a su sombra bidimensional

In[18]:=

Clear@tD;

milista3D = TableBcoords3Dhomogmovidas = TableB

1 0 0 0

0 1 0 0

0 0 1 2.4

0 0 0 1

.

1 0 0 0

0 Cos@2 ∗ π ∗ tD −Sin@2 ∗ π ∗ tD 0

0 Sin@2 ∗ π ∗ tD Cos@2 ∗ π ∗ tD 0

0 0 0 1

.

Part@coords3Dhomogeneas, kD, 8k, numcoords3D<F;

coords3Dhomogperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dnormalizadas = TableB Part@coords3Dhomogperspectiva, kDPart@coords3Dhomogperspectiva, k, 4D ,

8k, numcoords3D<F;

coords3Dmovidas = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dnormalizadas, kD,

8k, numcoords3D<F;Graphics3D@8GraphicsComplex@coords3Dmovidas, 8tubos3D, esferas3D< D,GraphicsComplex@coords3Dperspectiva, 8tubos3D, esferas3D< D

<,Axes → True, PlotRange → 88−2, 2<, 8−2, 2<, 80.9, 4.5<<D,

8t, 0.03, 1, 0.03<F;ListAnimate@milista3DD

6 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 7: Perspectiva en coordenadas homogéneas

Out[20]=

LAD0450perspectiva.nb 7

Printed by Wolfram Mathematica Student Edition

Page 8: Perspectiva en coordenadas homogéneas

ü La sombra bidimensional del cubo rotando, “atrapada” en el plano z=1

In[21]:=

Clear@tD;

milista3D = TableBcoords3Dhomogmovidas = TableB

1 0 0 0

0 1 0 0

0 0 1 2.4

0 0 0 1

.

1 0 0 0

0 Cos@2 ∗ π ∗ tD Sin@2 ∗ π ∗ tD 0

0 −Sin@2 ∗ π ∗ tD Cos@2 ∗ π ∗ tD 0

0 0 0 1

.

Part@coords3Dhomogeneas, kD, 8k, numcoords3D<F;

coords3Dmovidas = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dhomogperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dnormalizadas = TableB Part@coords3Dhomogperspectiva, kDPart@coords3Dhomogperspectiva, k, 4D ,

8k, numcoords3D<F;

coords3Dperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dnormalizadas, kD,

8k, numcoords3D<F;Graphics3D@8GraphicsComplex@coords3Dperspectiva, 8tubos3D, esferas3D< D<,Axes → True, PlotRange → 88−1, 1<, 8−1, 1<, 80.9, 1.1<<D,

8t, 0.03, 1, 0.03<F;ListAnimate@milista3DD

8 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 9: Perspectiva en coordenadas homogéneas

Out[23]=

ü Las coordenadas serán representadas con discos en lugar de esferas

In[24]:=

puntos = ReplaceAll@esferas3D, Sphere → DiskD

Out[24]= ::HueB 18F, Disk@1, 0.1D>, :HueB 1

4F, Disk@2, 0.1D>,

:HueB3

8F, Disk@3, 0.1D>, :HueB

1

2F, Disk@4, 0.1D>, :HueB

5

8F, Disk@5, 0.1D>,

:HueB3

4F, Disk@6, 0.1D>, :HueB

7

8F, Disk@7, 0.1D>, 8Hue@1D, Disk@8, 0.1D<>

ü Las aristas serán representadas con líneas en lugar de tubos

In[25]:=

lineas = ReplaceAll@tubos3D, Tube@p_, t_D :> Line@pDD

Out[25]= ::HueB1

28F, Line@81, 2<D>, :HueB

1

14F, Line@81, 3<D>, :HueB

3

28F, Line@81, 5<D>,

:HueB1

7F, Line@82, 4<D>, :HueB

5

28F, Line@82, 6<D>, :HueB

3

14F, Line@83, 4<D>,

:HueB 14F, Line@83, 7<D>, :HueB 2

7F, Line@84, 8<D>, :HueB 9

28F, Line@85, 6<D>,

:HueB5

14F, Line@85, 7<D>, :HueB

11

28F, Line@86, 8<D>, :HueB

3

7F, Line@87, 8<D>>

LAD0450perspectiva.nb 9

Printed by Wolfram Mathematica Student Edition

Page 10: Perspectiva en coordenadas homogéneas

ü La sombra bidimensional del cubo rotando, animación bidimensional

In[26]:=

Clear@tD;

milista3D = TableBcoords3Dhomogmovidas = TableB

1 0 0 0

0 1 0 0

0 0 1 2.4

0 0 0 1

.

1 0 0 0

0 Cos@2 ∗ π ∗ tD Sin@2 ∗ π ∗ tD 0

0 −Sin@2 ∗ π ∗ tD Cos@2 ∗ π ∗ tD 0

0 0 0 1

.

Part@coords3Dhomogeneas, kD, 8k, numcoords3D<F;

coords3Dmovidas = TableB1 0 0 0

0 1 0 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dhomogperspectiva = TableB1 0 0 0

0 1 0 0

0 0 1 0

0 0 1 0

.Part@coords3Dhomogmovidas, kD,

8k, numcoords3D<F;

coords3Dnormalizadas = TableB Part@coords3Dhomogperspectiva, kDPart@coords3Dhomogperspectiva, k, 4D ,

8k, numcoords3D<F;coords3Da2D = TableBK 1 0 0 0

0 1 0 0O.Part@coords3Dnormalizadas, kD,

8k, numcoords3D<F;Graphics@8Thick,GraphicsComplex@coords3Da2D, 8lineas, puntos< D

<,Axes → True, PlotRange → 88−1, 1<, 8−1, 1<<D,

8t, 0.03, 1, 0.03<F;ListAnimate@milista3DD

10 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 11: Perspectiva en coordenadas homogéneas

Out[28]=

-1.0 -0.5 0.5 1.0

-1.0

-0.5

0.5

1.0

Sombra con perspectiva en tres dimensiones de un hipercubo

tetradimensional

ü Generamos las coordenadas de los vértices del hipercubo unitario en 4D con el comando Tuples

In[29]:=

tuplas4D = Tuples@8−1, 1<, 4DOut[29]= 88−1, −1, −1, −1<, 8−1, −1, −1, 1<, 8−1, −1, 1, −1<,

8−1, −1, 1, 1<, 8−1, 1, −1, −1<, 8−1, 1, −1, 1<, 8−1, 1, 1, −1<,8−1, 1, 1, 1<, 81, −1, −1, −1<, 81, −1, −1, 1<, 81, −1, 1, −1<,81, −1, 1, 1<, 81, 1, −1, −1<, 81, 1, −1, 1<, 81, 1, 1, −1<, 81, 1, 1, 1<<

ü Obtenemos el número de coordenadas con el comando Length

In[30]:=

numcoords4D = Length@tuplas4DDOut[30]=

16

LAD0450perspectiva.nb 11

Printed by Wolfram Mathematica Student Edition

Page 12: Perspectiva en coordenadas homogéneas

ü Dibujaremos una esfera con centro en cada coordenada

In[31]:=

esferas4D = Table@8Hue@k ê numcoords4DD, Sphere@k, 0.1D<, 8k, numcoords4D<D

Out[31]= ::HueB 1

16F, Sphere@1, 0.1D>, :HueB 1

8F, Sphere@2, 0.1D>, :HueB 3

16F, Sphere@3, 0.1D>,

:HueB1

4F, Sphere@4, 0.1D>, :HueB

5

16F, Sphere@5, 0.1D>, :HueB

3

8F, Sphere@6, 0.1D>,

:HueB7

16F, Sphere@7, 0.1D>, :HueB

1

2F, Sphere@8, 0.1D>, :HueB

9

16F, Sphere@9, 0.1D>,

:HueB 58F, Sphere@10, 0.1D>, :HueB 11

16F, Sphere@11, 0.1D>,

:HueB 34F, Sphere@12, 0.1D>, :HueB 13

16F, Sphere@13, 0.1D>,

:HueB7

8F, Sphere@14, 0.1D>, :HueB

15

16F, Sphere@15, 0.1D>, 8Hue@1D, Sphere@16, 0.1D<>

12 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 13: Perspectiva en coordenadas homogéneas

ü Las aristas del hipercubo unitario se dibujarán como tubos. Primero se crean “conexiones” entre

todas las coordenadas, pero después seleccionamos sólo aquellas conexiones con una longitud

exactamente de 2 unidades, esas son las aristas de este hipercubo:

In[32]:=

todoslospares4D = Subsets@Range@numcoords4DD, 82<D;numpares4D = Length@todoslospares4DD;paresconectados4D =

Select@todoslospares4D,

Function@8par<, Norm@tuplas4D@@ par@@1DD DD − tuplas4D@@ par@@2DD DDD � 2DD;

numconectados4D = Length@paresconectados4DD;tubos4D = Table@8Hue@k ê numpares4DD, Tube@Part@paresconectados4D, kD, 0.05D<,

8k, numconectados4D<D

LAD0450perspectiva.nb 13

Printed by Wolfram Mathematica Student Edition

Page 14: Perspectiva en coordenadas homogéneas

Out[36]= ::HueB 1

120F, Tube@81, 2<, 0.05D>, :HueB 1

60F, Tube@81, 3<, 0.05D>,

:HueB1

40F, Tube@81, 5<, 0.05D>, :HueB

1

30F, Tube@81, 9<, 0.05D>,

:HueB1

24F, Tube@82, 4<, 0.05D>, :HueB

1

20F, Tube@82, 6<, 0.05D>,

:HueB 7

120F, Tube@82, 10<, 0.05D>, :HueB 1

15F, Tube@83, 4<, 0.05D>,

:HueB 3

40F, Tube@83, 7<, 0.05D>, :HueB 1

12F, Tube@83, 11<, 0.05D>,

:HueB11

120F, Tube@84, 8<, 0.05D>, :HueB

1

10F, Tube@84, 12<, 0.05D>,

:HueB13

120F, Tube@85, 6<, 0.05D>, :HueB

7

60F, Tube@85, 7<, 0.05D>,

:HueB 18F, Tube@85, 13<, 0.05D>, :HueB 2

15F, Tube@86, 8<, 0.05D>,

:HueB 17

120F, Tube@86, 14<, 0.05D>, :HueB 3

20F, Tube@87, 8<, 0.05D>,

:HueB19

120F, Tube@87, 15<, 0.05D>, :HueB

1

6F, Tube@88, 16<, 0.05D>,

:HueB7

40F, Tube@89, 10<, 0.05D>, :HueB

11

60F, Tube@89, 11<, 0.05D>,

:HueB 23

120F, Tube@89, 13<, 0.05D>, :HueB 1

5F, Tube@810, 12<, 0.05D>,

:HueB 5

24F, Tube@810, 14<, 0.05D>, :HueB 13

60F, Tube@811, 12<, 0.05D>,

:HueB9

40F, Tube@811, 15<, 0.05D>, :HueB

7

30F, Tube@812, 16<, 0.05D>,

:HueB29

120F, Tube@813, 14<, 0.05D>, :HueB

1

4F, Tube@813, 15<, 0.05D>,

:HueB 31

120F, Tube@814, 16<, 0.05D>, :HueB 4

15F, Tube@815, 16<, 0.05D>>

ü Convertimos las coordenadas (x,y,z,w) en coordenadas homogéneas (x,y,z,w,1)

In[37]:=

coords4Dhomogeneas = Table@Join@Part@tuplas4D, kD, 81<D, 8k, numcoords4D<DOut[37]= 88−1, −1, −1, −1, 1<, 8−1, −1, −1, 1, 1<, 8−1, −1, 1, −1, 1<, 8−1, −1, 1, 1, 1<,

8−1, 1, −1, −1, 1<, 8−1, 1, −1, 1, 1<, 8−1, 1, 1, −1, 1<, 8−1, 1, 1, 1, 1<,81, −1, −1, −1, 1<, 81, −1, −1, 1, 1<, 81, −1, 1, −1, 1<, 81, −1, 1, 1, 1<,81, 1, −1, −1, 1<, 81, 1, −1, 1, 1<, 81, 1, 1, −1, 1<, 81, 1, 1, 1, 1<<

14 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 15: Perspectiva en coordenadas homogéneas

ü Se aplica una matriz que corresponde a una traslación hacia “hiper-arriba”, en la dirección de la

cuarta coordenada w:

In[38]:=

coords4Dhomogmovidas =

TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 2.4

0 0 0 0 1

.Part@coords4Dhomogeneas, kD, 8k, numcoords4D<F

Out[38]= 88−1., −1., −1., 1.4, 1.<, 8−1., −1., −1., 3.4, 1.<,8−1., −1., 1., 1.4, 1.<, 8−1., −1., 1., 3.4, 1.<,8−1., 1., −1., 1.4, 1.<, 8−1., 1., −1., 3.4, 1.<, 8−1., 1., 1., 1.4, 1.<,8−1., 1., 1., 3.4, 1.<, 81., −1., −1., 1.4, 1.<, 81., −1., −1., 3.4, 1.<,81., −1., 1., 1.4, 1.<, 81., −1., 1., 3.4, 1.<, 81., 1., −1., 1.4, 1.<,81., 1., −1., 3.4, 1.<, 81., 1., 1., 1.4, 1.<, 81., 1., 1., 3.4, 1.<<

ü Se aplica una matriz que corresponde a una proyección con perspectiva en el hiperplano w=1

In[39]:=

coords4Dhomogperspectiva =

TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 1 0

.Part@coords4Dhomogmovidas, kD, 8k, numcoords4D<F

Out[39]= 88−1., −1., −1., 1.4, 1.4<, 8−1., −1., −1., 3.4, 3.4<,8−1., −1., 1., 1.4, 1.4<, 8−1., −1., 1., 3.4, 3.4<,8−1., 1., −1., 1.4, 1.4<, 8−1., 1., −1., 3.4, 3.4<, 8−1., 1., 1., 1.4, 1.4<,8−1., 1., 1., 3.4, 3.4<, 81., −1., −1., 1.4, 1.4<, 81., −1., −1., 3.4, 3.4<,81., −1., 1., 1.4, 1.4<, 81., −1., 1., 3.4, 3.4<, 81., 1., −1., 1.4, 1.4<,81., 1., −1., 3.4, 3.4<, 81., 1., 1., 1.4, 1.4<, 81., 1., 1., 3.4, 3.4<<

LAD0450perspectiva.nb 15

Printed by Wolfram Mathematica Student Edition

Page 16: Perspectiva en coordenadas homogéneas

ü Se “renormalizan” las coordenadas para que la quinta coordenada sea 1, es decir, (x,y,z,w,1)

In[40]:=

coords4Dnormalizadas =

TableB Part@coords4Dhomogperspectiva, kDPart@coords4Dhomogperspectiva, k, 4D , 8k, numcoords4D<F

Out[40]= 88−0.714286, −0.714286, −0.714286, 1., 1.<,8−0.294118, −0.294118, −0.294118, 1., 1.<,8−0.714286, −0.714286, 0.714286, 1., 1.<,8−0.294118, −0.294118, 0.294118, 1., 1.<,8−0.714286, 0.714286, −0.714286, 1., 1.<,8−0.294118, 0.294118, −0.294118, 1., 1.<, 8−0.714286, 0.714286, 0.714286, 1., 1.<,8−0.294118, 0.294118, 0.294118, 1., 1.<, 80.714286, −0.714286, −0.714286, 1., 1.<,80.294118, −0.294118, −0.294118, 1., 1.<,80.714286, −0.714286, 0.714286, 1., 1.<, 80.294118, −0.294118, 0.294118, 1., 1.<,80.714286, 0.714286, −0.714286, 1., 1.<, 80.294118, 0.294118, −0.294118, 1., 1.<,80.714286, 0.714286, 0.714286, 1., 1.<, 80.294118, 0.294118, 0.294118, 1., 1.<<

ü Pasamos de las coordenadas homogéneas (x,y,z,w,1) a la protección tridimensional (x,y,z)

In[41]:=

coords4Da3D = TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

.Part@coords4Dnormalizadas, kD, 8k, numcoords4D<F

Out[41]= 88−0.714286, −0.714286, −0.714286<, 8−0.294118, −0.294118, −0.294118<,8−0.714286, −0.714286, 0.714286<, 8−0.294118, −0.294118, 0.294118<,8−0.714286, 0.714286, −0.714286<, 8−0.294118, 0.294118, −0.294118<,8−0.714286, 0.714286, 0.714286<, 8−0.294118, 0.294118, 0.294118<,80.714286, −0.714286, −0.714286<, 80.294118, −0.294118, −0.294118<,80.714286, −0.714286, 0.714286<, 80.294118, −0.294118, 0.294118<,80.714286, 0.714286, −0.714286<, 80.294118, 0.294118, −0.294118<,80.714286, 0.714286, 0.714286<, 80.294118, 0.294118, 0.294118<<

16 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 17: Perspectiva en coordenadas homogéneas

ü Sombra tridimensional del hipercubo

In[42]:=

Graphics3D@8GraphicsComplex@coords4Da3D, 8tubos4D, esferas4D< D<,Axes → TrueD

Out[42]=

LAD0450perspectiva.nb 17

Printed by Wolfram Mathematica Student Edition

Page 18: Perspectiva en coordenadas homogéneas

ü La sombra tridimensional del hipercubo rotando, animación tridimensional

In[43]:=

Clear@tD;

milista4D = TableBcoords4Dhomogmovidas = TableB

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 2.4

0 0 0 0 1

.

1 0 0 0 0

0 1 0 0 0

0 0 Cos@2 ∗ π ∗ tD Sin@2 ∗ π ∗ tD 0

0 0 −Sin@2 ∗ π ∗ tD Cos@2 ∗ π ∗ tD 0

0 0 0 0 1

.

Part@coords4Dhomogeneas, kD, 8k, numcoords4D<F;

coords4Dmovidas = TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

.Part@coords4Dhomogmovidas, kD,

8k, numcoords4D<F;

coords4Dhomogperspectiva = TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 1 0

.

Part@coords4Dhomogmovidas, kD, 8k, numcoords4D<F;

coords4Dnormalizadas = TableB Part@coords4Dhomogperspectiva, kDPart@coords4Dhomogperspectiva, k, 4D ,

8k, numcoords4D<F;

coords4Da3D = TableB1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

.Part@coords4Dnormalizadas, kD,

8k, numcoords4D<F;Graphics3D@8GraphicsComplex@coords4Da3D, 8tubos4D, esferas4D< D<,Axes → True, PlotRange → 88−1, 1<, 8−1, 1<, 8−1, 1<<D,

8t, 0.03, 1, 0.03<F;ListAnimate@milista4DD

18 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition

Page 19: Perspectiva en coordenadas homogéneas

Out[45]=

Ejercicio: Modifica la animación para que gire como en este video de youtube:

http://www.youtube.com/watch?v=5xN4DxdiFrs

Modifica la animación para que gire como en este video de youtube:

http://www.youtube.com/watch?v=5xN4DxdiFrs

Fin

In[46]:=

$Version

Out[46]=9.0 for Microsoft Windows H64−bitL HJanuary 25, 2013L

LAD0450perspectiva.nb 19

Printed by Wolfram Mathematica Student Edition

Page 20: Perspectiva en coordenadas homogéneas

In[47]:=

DateString@DOut[47]=

Tue 29 Dec 2015 14:05:45

José Luis Gómez-Muñoz

http://homepage.cem.itesm.mx/jose.luis.gomez

20 LAD0450perspectiva.nb

Printed by Wolfram Mathematica Student Edition