X Tutup
Skip to content

Commit 774b80e

Browse files
committed
new volume rendering example
1 parent eac26cd commit 774b80e

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {
7+
"collapsed": true
8+
},
9+
"outputs": [],
10+
"source": [
11+
"import numpy as np\n",
12+
"import ipyvolume"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": 4,
18+
"metadata": {
19+
"collapsed": true
20+
},
21+
"outputs": [],
22+
"source": [
23+
"N = 256\n",
24+
"x = np.linspace(0.0, 1.0, N)\n",
25+
"y = np.linspace(0.0, 1.0, N)\n",
26+
"z = np.linspace(0.0, 1.0, N)\n",
27+
"\n",
28+
"x3d, y3d, z3d = np.meshgrid(x, y, z, indexing=\"ij\")\n",
29+
"\n",
30+
"r = np.sqrt((x3d - 0.5)**2 + (y3d - 0.5)**2 + (z3d - 0.5)**2)"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 14,
36+
"metadata": {
37+
"collapsed": false
38+
},
39+
"outputs": [],
40+
"source": [
41+
"f = 1.0 + np.sin(x3d*np.pi*5)*np.sin(y3d*np.pi*7)*np.cos(z3d*np.pi*2) * np.exp(-r**2/0.25**2)"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 15,
47+
"metadata": {
48+
"collapsed": true
49+
},
50+
"outputs": [],
51+
"source": [
52+
"a = ipyvolume.volshow(f)"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 16,
58+
"metadata": {
59+
"collapsed": false
60+
},
61+
"outputs": [
62+
{
63+
"data": {
64+
"application/vnd.jupyter.widget-view+json": {
65+
"model_id": "bf1db95101004b669e617436c1b7570b"
66+
}
67+
},
68+
"metadata": {},
69+
"output_type": "display_data"
70+
}
71+
],
72+
"source": [
73+
"a"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {
80+
"collapsed": true
81+
},
82+
"outputs": [],
83+
"source": []
84+
}
85+
],
86+
"metadata": {
87+
"kernelspec": {
88+
"display_name": "Python 3",
89+
"language": "python",
90+
"name": "python3"
91+
},
92+
"language_info": {
93+
"codemirror_mode": {
94+
"name": "ipython",
95+
"version": 3
96+
},
97+
"file_extension": ".py",
98+
"mimetype": "text/x-python",
99+
"name": "python",
100+
"nbconvert_exporter": "python",
101+
"pygments_lexer": "ipython3",
102+
"version": "3.5.2"
103+
}
104+
},
105+
"nbformat": 4,
106+
"nbformat_minor": 2
107+
}

0 commit comments

Comments
 (0)
X Tutup