gpt4 book ai didi

Plotly:渲染 3D 网格椭球体时的视觉伪像

转载 作者:行者123 更新时间:2023-12-05 06:00:39 27 4
gpt4 key购买 nike

使用以下代码:


import numpy as np

from plotly.offline import iplot, init_notebook_mode

import plotly.graph_objects as go
from numpy import sin, cos, pi

a = 6378.137 # centre-equator axis
c = 6357 # centre-north pole axis

phi = np.linspace(0, 2*pi)
theta = np.linspace(-pi/2, pi/2)
phi, theta = np.meshgrid(phi, theta)

x = a * cos(theta) * sin(phi)
y = a * cos(theta) * cos(phi)
z = c * sin(theta)

init_notebook_mode()

mesh = go.Mesh3d(
{
'x': x.flatten(),
'y': y.flatten(),
'z': z.flatten(),
'alphahull': 0.8,
}
)


layout = go.Layout(
scene=dict(aspectmode='data')
)

figure = go.Figure(data=[mesh], layout=layout)

iplot(figure)


我得到了我想要的椭圆体。只有0子午线上有一个伪影,如图所示:

enter image description here

知道如何删除多余的行吗?

---- 编辑:赏金之后

经过几分钟的尝试,并尝试了Dice提出的解决方案并没有解决问题:

import numpy as np

import plotly.offline as pyo
import plotly.graph_objs as go

a = 6378.137 # centre-equator axis
c = 6357 # centre-north pole axis

phi = np.linspace(0, 2*np.pi, endpoint=False)
theta = np.linspace(-np.pi/2, np.pi/2, endpoint=False)
phi, theta = np.meshgrid(phi, theta)

x = a * np.cos(theta) * np.sin(phi)
y = a * np.cos(theta) * np.cos(phi)
z = c * np.sin(theta)


fig = go.Figure(
data=[
go.Mesh3d(
x=x.flatten(),
y=y.flatten(),
z=z.flatten(),
opacity=0.5,
)
]
)


fig.show()

显示:

more artefacts

这是比以前更多的人工制品。不过,对于当前的 plotly 版本和 python 3.9,这些都是我拥有的人工制品,即使没有端点=False。

要求(python 3.9.9):

numpy==1.22.0
plotly==5.5.0

问题仍然悬而未决!

最佳答案

这似乎是由端点上的网格重叠引起的,从 phi 和 theta 中删除端点解决了这个问题。

phi = np.linspace(0, 2*pi, endpoint=False)
theta = np.linspace(-pi/2, pi/2, endpoint=False)

更改此位应该可以解决问题。

关于Plotly:渲染 3D 网格椭球体时的视觉伪像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67567972/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com