gpt4 book ai didi

python - 将 3d 钻孔轨迹转换为笛卡尔坐标并使用 matplotlib 绘制

转载 作者:太空宇宙 更新时间:2023-11-03 13:18:56 25 4
gpt4 key购买 nike

我希望能够使用方向和距离绘制两条线。这是一个钻孔轨迹,所以我现在有这种格式的数据,

enter image description here

深度实际上是孔下的距离,而不是垂直深度。方位角来自磁北。倾角基于 0 是水平的。我想根据此类信息从同一点(0,0,0 很好)绘制两条线,看看它们有何不同。

我没有使用 Matplotlib 的经验,但对 Python 很熟悉,并且想了解这个绘图工具。我找到了 this page它有助于理解框架,但我仍然无法弄清楚如何使用 3d 矢量绘制线条。有人可以给我一些关于如何执行此操作或在哪里可以找到我需要的指示的指示吗?谢谢

最佳答案

将您的坐标转换为笛卡尔坐标并使用 matplotlib 绘制并包含注释的脚本:

import numpy as np
import matplotlib.pyplot as plt
# import for 3d plot
from mpl_toolkits.mplot3d import Axes3D
# initializing 3d plot
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
# several data points
r = np.array([0, 14, 64, 114])
# get lengths of the separate segments
r[1:] = r[1:] - r[:-1]
phi = np.array([255.6, 255.6, 261.7, 267.4])
theta = np.array([-79.5, -79.5, -79.4, -78.8])
# convert to radians
phi = phi * 2 * np.pi / 360.
# in spherical coordinates theta is measured from zenith down; you are measuring it from horizontal plane up
theta = (90. - theta) * 2 * np.pi / 360.
# get x, y, z from known formulae
x = r*np.cos(phi)*np.sin(theta)
y = r*np.sin(phi)*np.sin(theta)
z = r*np.cos(theta)
# np.cumsum is employed to gradually sum resultant vectors
ax.plot(np.cumsum(x),np.cumsum(y),np.cumsum(z))

关于python - 将 3d 钻孔轨迹转换为笛卡尔坐标并使用 matplotlib 绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20687164/

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