-2
我想要繪製出球體表面上的矩形區域。繪製球體表面上的矩形區域
這是我對球的代碼:
import numpy as np
import random as rand
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
theta, phi = np.mgrid[0:2*np.pi : 20j ,0:np.pi : 20j]
r = 6.3
x = r * np.cos(phi)*np.sin(theta)
y = r * np.sin(phi)*np.sin(theta)
z = r * np.cos(theta)
ax.plot_wireframe(x,y,z, color = "k")
plt.show()
這些點將從緯度/經度被轉換到購物車COORDS。
lat1x = 46.49913179 * (2*np.pi/360)
lat2x = 46.4423682 * (2*np.pi/360)
long1y = -119.4049072 * (2*np.pi/360)
long2y = -119.5048141 * (2*np.pi/360)
lat3x = 46.3973998 * (2*np.pi/360)
lat4x = 46.4532495 * (2*np.pi/360)
long3y = -119.4495392 * (2*np.pi/360)
long4y = -119.3492884 * (2*np.pi/360)
xw1 = r * np.cos(lat1x)*np.cos(long1y)
yw1 = r * np.cos(lat1x)*np.sin(long1y)
zw1 = r * np.sin(lat1x)
xw2 = r * np.cos(lat2x)*np.cos(long2y)
yw2 = r * np.cos(lat2x)*np.sin(long2y)
zw2 = r * np.sin(lat2x)
xw3 = r * np.cos(lat3x)*np.cos(long3y)
yw3 = r * np.cos(lat3x)*np.sin(long3y)
zw3 = r * np.sin(lat3x)
xw4 = r * np.cos(lat4x)*np.cos(long4y)
yw4 = r * np.cos(lat4x)*np.sin(long4y)
zw4 = r * np.sin(lat4x)
p1 = [xw1,yw1,zw1]
p2 = [xw2,yw2,zw2]
p3 = [xw3,yw3,zw3]
p4 = [xw4,yw4,zw4]
ax.scatter(p1,p2,p3,p4, color = "r")
這些是點和那裏轉換到笛卡爾座標我很難讓它們出現在球體的表面上。它們也應該形成粗糙的矩形形狀。我希望能夠連接點在球體表面繪製一個矩形。因爲矩形的意思是非常小的
「我想」 似乎是一種委婉說法。你有沒有嘗試過什麼?在這種情況下,「痕跡」是什麼意思?繪圖的座標是哪一個?預期情節如何? – ImportanceOfBeingErnest