Hey all,
I am trying to draw 3D cylinder. I have points of X, Y, Z. This is the function i used:
import numpy as np
import plotly.graph_objects as go
from scipy.linalg import norm
well_data = np.loadtxt("well.dat", dtype=float)
fig = go.Figure()
for i in range(162):
p0 = well_data[i]
p1 = well_data[i+1]
R= 4
v = p1 - p0
#find magnitude of vector
mag = norm(v)
#unit vector in direction of axis
v = v / mag
#make some vector not in the same direction as v
not_v = np.array([1, 0, 0])
if (v == not_v).all():
not_v = np.array([0, 1, 0])
#make vector perpendicular to v
n1 = np.cross(v, not_v)
#normalize n1
n1 /= norm(n1)
#make unit vector perpendicular to v and n1
n2 = np.cross(v, n1)
#surface ranges over t from 0 to length of axis and 0 to 2*pi
t = np.linspace(0, mag, 100)
theta = np.linspace(0, 2 * np.pi, 100)
#use meshgrid to make 2d arrays
t, theta = np.meshgrid(t, theta)
#generate coordinates for surface
X, Y, Z = [p0[i] + v[i] * t + R * np.sin(theta) * n1[i] + R * np.cos(theta) * n2[i] for i in [0, 1, 2]]
fig.add_trace(go.Surface(x=X, y=Y, z=Z, showscale=False))
fig.show()
It draws the cylinder along given points but it takes lot of time and if i move the axes figure freezes. Is there another way to achieve this with plotly and python ?
Best Regards.
3D Line Plot:
3D Cylinder Plot
i would like to create something like below
well data x,y,z:
268100.49 1184787.3 0
268100.47 1184787.7 176
268100.18 1184788.19 290.4
268099.51 1184788.79 377
268098.04 1184789.96 481.3
268097.63 1184790.23 501.1
268097.07 1184790.56 519.6
268096.18 1184790.97 539.5
268094.93 1184791.43 559.2
268093.26 1184791.84 578.6
268091.26 1184792.09 597.2
268088.91 1184792.13 616.1
268086.2 1184791.86 635.3
268083.17 1184791.24 654.4
268079.62 1184790.4 674
268075.83 1184789.59 692.7
268071.53 1184788.59 712
268066.67 1184787.28 731.8
268061.57 1184785.78 750.8
268056.01 1184784.12 770.1
268050.1 1184782.35 789.4
268043.95 1184780.43 808.4
268037.37 1184778.3 827.4
268030.25 1184775.99 846.5
268022.56 1184773.49 866
268014.61 1184770.93 885.2
267998.78 1184765.9 921.6
267989.98 1184763.08 941.3
267981.21 1184760.22 960.5
267972.31 1184757.4 979.2
267962.76 1184754.43 998.5
267952.88 1184751.29 1017.6
267942.69 1184748.02 1036.6
267931.82 1184744.6 1056.9
267922.22 1184741.63 1075
267912.25 1184738.62 1094
267902.32 1184735.72 1113.2
267892.33 1184732.92 1132.3
267882.13 1184730.09 1151.2
267871.25 1184726.99 1171.1
267860.44 1184723.9 1190.7
267849.83 1184720.87 1209.9
267839.6 1184717.97 1228.6
267828.79 1184714.87 1248.3
267818.31 1184711.83 1267.3
267808.01 1184708.9 1285.9
267797.48 1184705.97 1304.8
267786.53 1184703.04 1324.3
267776 1184700.23 1343.3
267764.78 1184697.09 1364.1
267755.13 1184694.23 1382.4
267745.19 1184691.29 1401.4
267735.14 1184688.37 1420.5
267724.76 1184685.37 1440.1
267714.52 1184682.49 1459.3
267704.18 1184679.59 1478.9
267694.59 1184676.87 1497.3
267684.56 1184674.09 1516.4
267674.53 1184671.24 1535.6
267664.59 1184668.23 1554.8
267654.83 1184665.26 1573.6
267644.63 1184662.2 1593.2
267634.68 1184659.24 1612.2
267624.31 1184656.04 1632
267614.31 1184652.79 1651.2
267604.04 1184649.42 1671.1
267594.83 1184646.43 1689.1
267589.92 1184644.88 1698.7
267580.21 1184641.96 1717.6
267570.04 1184639 1737.5
267560.43 1184636.39 1756.3
267553.06 1184634.47 1770.7
267542.83 1184631.79 1790.9
267532.77 1184629.15 1810.8
267522.78 1184626.45 1830.3
267512.92 1184623.65 1849.2
267502.65 1184620.72 1868.5
267492.18 1184617.82 1887.9
267481.7 1184614.9 1907.1
267471.21 1184611.73 1926.1
267460.9 1184608.47 1944.7
267450.45 1184605.21 1963.8
267439.9 1184601.9 1983.2
267429.42 1184598.79 2002.2
267418.94 1184595.81 2021.3
267408.29 1184592.65 2040.8
267397.66 1184589.51 2060.3
267387.61 1184586.65 2079
267377.59 1184583.82 2098
267367.86 1184581.14 2117.1
267358.31 1184578.43 2136.9
267349.63 1184575.85 2155.8
267341.07 1184573.33 2174.9
267332.6 1184570.78 2194.2
267324.59 1184568.11 2213.2
267316.7 1184565.33 2232.4
267308.77 1184562.63 2252.1
267301.32 1184560.15 2271.2
267294.28 1184557.74 2290.4
267287.63 1184555.46 2309.8
267281.55 1184553.26 2328.7
267275.69 1184551.04 2347.8
267270.08 1184549.09 2366.9
267264.55 1184547.25 2387
267259.38 1184545.59 2406.3
267254.36 1184544.15 2424.9
267249.07 1184542.64 2444.5
267244.1 1184541.19 2463
267239.08 1184539.7 2482
267234.08 1184538.03 2501.3
267229.17 1184536.27 2520.3
267223.8 1184534.39 2540.7
267218.73 1184532.66 2559.6
267213.59 1184530.89 2578.6
267208.64 1184528.91 2597.7
267203.87 1184526.7 2617
267199.16 1184524.5 2636.4
267194.75 1184522.45 2654.9
267190.02 1184520.26 2674.8
267185.45 1184518.24 2694
267180.99 1184516.35 2713
267176.38 1184514.45 2732.6
267171.82 1184512.63 2751.8
267167.39 1184510.87 2770.6
267162.92 1184509.06 2789.6
267158.5 1184507.25 2808.8
267154.01 1184505.38 2828.7
267149.74 1184503.54 2847.6
267145.51 1184501.75 2866.7
267141.48 1184500.19 2885.6
267137.49 1184498.69 2905.2
267133.8 1184497.32 2923.6
267129.92 1184495.84 2943.3
267126.33 1184494.45 2962.4
267122.72 1184493.06 2981.8
267119.29 1184491.8 3000.3
267115.71 1184490.61 3019.4
267111.92 1184489.51 3038.5
267108.03 1184488.35 3057.5
267102.3 1184486.71 3083.5
267095.73 1184485.1 3108.8
267092.31 1184484.33 3121.1
267087 1184483.1 3140.7
267082.02 1184481.84 3159.3
267076.71 1184480.42 3178.6
267071.05 1184478.84 3198.4
267065.57 1184477.3 3217.1
267058.36 1184475.45 3241.5
267052.6 1184473.93 3260.5
267047.94 1184472.59 3275.1
267041.81 1184470.87 3293.7
267035.3 1184469.07 3313
267028.77 1184467.26 3331.9
267021.78 1184465.31 3351.6
267015.01 1184463.4 3370.4
267008.05 1184461.56 3389.3
267000.55 1184459.73 3409.3
266993.39 1184458.04 3428.3
266986.1 1184456.35 3447.8
266979.24 1184454.93 3466.6
266972.23 1184453.72 3486.1
266969.44 1184453.27 3493.8
266963.57 1184452.33 3510```