Esfera
Publicado por angelo (1 intervención) el 14/09/2016 18:01:47
Existe alguna función en python que sea equivalente a sphere(r) de matlab que entregue las coordenadas X,Y,Z
Valora esta pregunta


0
# -*- coding: utf-8 -*-
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
def sphere(r):
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = r * np.outer(np.cos(u), np.sin(v))
y = r * np.outer(np.sin(u), np.sin(v))
z = r * np.outer(np.ones(np.size(u)), np.cos(v))
return x,y,z
x,y,z = sphere(2)
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b')
plt.show()