python绘制三维图像球_【python】读取三维点云球坐标数据并动态生成三维图像与着色...

import numpy as np

import math

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.animation import FuncAnimation

f=open('data.txt','r')

point=f.read()

f.close()

l1=point.replace('\n',',')

l2=l1.replace(' ',',')

l3=l2.split(',')

#print(l3)

m1=np.array(l3)

m2=m1.reshape(2664,6)

m3=[]

for each in m2:

each_line=list(map(lambda x:float(x),each))

m3.append(each_line)

m4=np.array(m3)

print(m4)

yaw=[i[0] for i in m4]

pitch=[i[1] for i in m4]

radius=[i[2] for i in m4]

c1=[i[3:6] for i in m4]

c2=np.array(c1)

c3=c2.reshape(2664,3)

print(c3)

x=[]

y=[]

z=[]

for i in range(len(m4)):

x.append(radius[i]*math.sin(0.0174532924*pitch[i])*math.sin(0.0174532924*yaw[i]))

y.append(radius[i]*math.cos(0.0174532924*pitch[i]))

z.append(radius[i]*math.sin(0.0174532924*pitch[i])*math.cos(0.0174532924*yaw[i]))

# print(x)

# print(y)

# print(z)

def animate():

return point

def init():

return point

fig=plt.figure(figsize=(16,9),dpi=120)

ax=fig.add_subplot(111,projection='3d')

plt.title('point')

ax.set_xlabel('X Label')

ax.set_ylabel('Z Label')

ax.set_zlabel('Y Label')

anim = FuncAnimation(fig,animate, frames=np.arange(100), init_func=init,

interval=100, blit=True)

for i in range(2664):

point=ax.scatter(z[i],x[i],y[i],c=(c3[i]/255),marker='.',s=10,linewidth=1,alpha=1,cmap='spectral')

plt.ion()

plt.pause(0.01)

plt.close

plt.show()

视频地址:点击打开链接

数据点未进行着色时的情况显示如下:

6f594a78cab6e928e1722515c9268544.jpg

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值