Docsity

Ejercicios vectores Python, Ejercicios de Programación Lineal

Toggle sidebar
bg1
PROGRAMACIÓN II
VECTORES
Taller . Representación de vectores 3D
__Integrantes:__Bruno Jiménez, David Cartagena
__Fecha:__1/06/2025
UNIVERSIDAD CENTRAL DEL ECUADOR
CALIFICACIÓN: 16.7
Representación de un punto en el plano 3D
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure() #Creación de la figura 3D
ax = fig.add_subplot(111,projection='3d', autoscale_on=True, aspect='equal')
x=1
y=1
z=1
ax.scatter(x,y,z, c='r', marker='o') # Dibujar punto
ax.set_xlabel('Eje x')
ax.set_ylabel('Eje y')
ax.set_zlabel('Eje z')
plt.show()
Representar de un vector en el plano 3D
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')
origen=np.array([0,0,0])
vector=np.array([1,1,1])
ax.quiver(origen[0],origen[1],origen[2],vector[0],vector[1],vector[2], color='r', label='Vector')
ax.set_xlabel('Eje x')
ax.set_ylabel('Eje y')
ax.set_zlabel('Eje z')
ax.set_xlim([0,max(vector[0],1)])
ax.set_ylim([0,max(vector[1],1)])
ax.set_zlim([0,max(vector[2],1)])
pf3
pf4

Vista previa parcial del texto

¡Descarga Ejercicios vectores Python y más Ejercicios en PDF de Programación Lineal solo en Docsity!

PROGRAMACIÓN II

VECTORES

Taller. Representación de vectores 3D

__Integrantes:__Bruno Jiménez, David Cartagena

__Fecha:__1/06/

UNIVERSIDAD CENTRAL DEL ECUADOR

^ CALIFICACIÓN: 16.

^ Representación de un punto en el plano 3D

import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() #Creación de la figura 3D ax = fig.add_subplot(111,projection='3d', autoscale_on=True, aspect='equal') x=1y= z= ax.scatter(x,y,z,ax.set_xlabel('Eje c='r', x') marker='o') # Dibujar punto ax.set_ylabel('Ejeax.set_zlabel('Eje y')z') plt.show()

^ Representar de un vector en el plano 3D

import matplotlib.pyplot as plt fromimport mpl_toolkits.mplot3d numpy as np import Axes3D fig=plt.figure() ax=fig.add_subplot(111,projection='3d') origen=np.array([0,0,0])vector=np.array([1,1,1]) ax.quiver(origen[0],origen[1],origen[2],vector[0],vector[1],vector[2], color='r', label='Vector') ax.set_xlabel('Ejeax.set_ylabel('Eje x')y') ax.set_zlabel('Eje z') ax.set_xlim([0,max(vector[0],1)])ax.set_ylim([0,max(vector[1],1)]) ax.set_zlim([0,max(vector[2],1)])

ax.legend()plt.show()

^ Representación dinámica de un vector en el plano 3D

x 4 y - z 5

<function main.plot_vector(x, y, z)>

import from mpl_toolkits.mplot3d matplotlib.pyplot as import plt Axes3D from ipywidgets import interact def fig=plt.figure plot_vector(x(),y,z): ax=fig.add_subplot( 111 ,projection='3d') origen=np.array vector=np.array([([ (^0) x,, (^0) y,, (^0) z])]) ax.quiver(origen[ 0 ],origen[ 1 ],origen[ 2 ],vector[ 0 ],vector[ 1 ],vector[ 2 ], color='r', label='Vector') ax.set_xlabel ax.set_ylabel(('Eje'Eje x'y')) ax.set_zlabel('Eje z') ax.set_xlim ax.set_ylim([([-10-10,,maxmax((vectorvector[[ 01 ],], 11 )]))]) ax.set_zlim([-10,max(vector[ 2 ], 1 )]) ax.legend plt.show()() interact(plot_vector, x=(-10, 10 , 1 ),y=(-10, 10 , 1 ),z=(-10, 10 , 1 ))

Calcular la distancia entre dos puntos en el plano 3D

ax=fig.add_subplot( 111 ,projection='3d') origen=np.array([ 0 , 0 , 0 ]) ax.quiver(origen[ 0 ],origen[ 1 ],origen[ 2 ],P[ 0 ],P[ 1 ],P[ 2 ], color='b', label='P') ax.quiver ax.quiver((origenorigen[[ 00 ],],origenorigen[[ 11 ],],origenorigen[[ 22 ],],Qcruz[ 0 ],[Q 0 [], 1 ],cruzQ[ (^2) [], 1 ], color=cruz[ 2 'g'], ,color= label='r''Q', )label='P_Cruz') ax.set_xlabel('Eje x') ax.set_ylabel ax.set_zlabel(('Eje'Eje y'z')) ax.set_xlim([-10,max(P[ 0 ], 1 )]) ax.set_ylim ax.set_zlim([([-5-15,max,max(P([P (^1) [], 2 ], 1 )]) 1 )]) ax.set_xlim([-10,max(Q[ 0 ], 1 )]) ax.set_ylim ax.set_zlim([([-5-15,max,max(Q([Q (^1) [], 2 ], 1 )]) 1 )]) ax.set_xlim([-10,max(cruz[ 0 ], 1 )]) ax.set_ylim ax.set_zlim([([-5-15,max,max(cruz(cruz[ (^1) [], 2 ], 1 )]) 1 )]) ax.set_title('Producto cruz de dos vectores') ax.legend plt.show()()

Gracias por su atención