-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,348 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
from vtkplotter import Plotter, mag, Points, Point | ||
import numpy as np | ||
|
||
|
||
dt = 0.002 | ||
y = [25.0, -10.0, -7.0] # Starting point (initial condition) | ||
y = (25.0, -10.0, -7.0) # Starting point (initial condition) | ||
pts, cols = [], [] | ||
|
||
|
||
for t in np.linspace(0, 20, int(20 / dt)): | ||
# Integrate a funny differential equation | ||
dydt = np.array( | ||
[-8 / 3.0 * y[0] + y[1] * y[2], -10.0 * (y[1] - y[2]), -y[1] * y[0] + 28.0 * y[1] - y[2]] | ||
[-8 / 3.0 * y[0] + y[1] * y[2], | ||
-10.0 * (y[1] - y[2]), | ||
-y[1] * y[0] + 28.0 * y[1] - y[2]] | ||
) | ||
y = y + dydt * dt | ||
|
||
c = np.clip([mag(dydt) * 0.005], 0, 1)[0] # color by speed | ||
c = np.clip([np.linalg.norm(dydt) * 0.005], 0, 1)[0] # color by speed | ||
cols.append([c, 0, 1-c]) | ||
pts.append(y) | ||
cols.append([c, 0, 1 - c]) | ||
|
||
scene = Plotter(title="Lorenz attractor", axes=2, verbose=0, bg="w") | ||
scene += Point(y, r=20, c="g") | ||
scene += Points(pts, r=5, c=cols) | ||
scene.show() | ||
|
||
from vtkplotter import Plotter, Line, Point, Points, settings | ||
settings.renderPointsAsSpheres = False # render points as squares | ||
|
||
scene = Plotter(title="Lorenz attractor", axes=1, verbose=0, bg="w") | ||
scene += Point(y, r=10, c="g") # end point | ||
scene += Points(pts, r=3, c=cols) | ||
scene += Line(pts).off().addShadow(x=3) # only show shadow, not line | ||
scene += Line(pts).off().addShadow(z=-30) | ||
scene.show(viewup='z') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Mouse hind limb growth from day 10 9h to day 15 21h | ||
""" | ||
from vtkplotter import * | ||
|
||
objs = load(datadir+'timecourse1d.npy') # list of vtkActors | ||
|
||
# show the biggest and continue (return a Plotter instance) | ||
vp = show(objs[-1], axes=True, interactive=False) | ||
vp.actors = objs # set Plotter internal list of objs to be shown | ||
|
||
# switch off all the others | ||
[objs[i].c('gold').lw(2.0).off() for i in range(1, len(objs))] | ||
|
||
k = 0 # visible actor index | ||
def sliderfunc(widget, event): | ||
global k | ||
vp.actors[k].off() #switch off | ||
k = int(widget.GetRepresentation().GetValue()) | ||
vp.actors[k].on() #switch on | ||
days = int((k+249)/24) | ||
hours = ' %2sh (' % (k+249 -days*24) | ||
limbage = str(days)+ "d"+ hours + str(k+249)+"h)" | ||
widget.GetRepresentation().SetTitleText(limbage) | ||
|
||
vp.addSlider2D(sliderfunc, 0, len(objs)-1, | ||
pos=[(0.4,0.1), (0.9,0.1)], showValue=False) | ||
|
||
vp += Text(__doc__, font='SpecialElite', s=1.2) | ||
vp += load(datadir+'images/limbs_tc.jpg').scale(0.0154).y(10.0) | ||
vp += Line([(0,8), (0,10), (28.6,10), (4.5,8)], c='gray') | ||
|
||
vp.show(zoom=1.2, interactive=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "7811126ce93c494bb80ce84c8003236d", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[4.5, 4.5, 4.5, 0.0, 0.0, 0.0, 1.0, …" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"from vtkplotter import *\n", | ||
"\n", | ||
"bu = load(datadir+'bunny.obj')\n", | ||
"\n", | ||
"bu.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Manually set the k3d camera. Syntax is:\n", | ||
"# [posx,posy,posz, targetx,targety,targetz, upx,upy,upz]\n", | ||
"settings.notebook_plotter.camera = [0., 0. ,1.,\n", | ||
" 0., 0., 0.,\n", | ||
" 0., 1., 0.]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[1mk3dcam is [-0.0068 0.044 0.192 -0.017 0.11 0.08 0. 1. 0. ]\u001b[0m\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Convert a vtkCamera object into the appropiate K3D list\n", | ||
"import vtk\n", | ||
"vcam = vtk.vtkCamera()\n", | ||
"vcam.SetPosition( [-0.017, 0.11, 0.48] )\n", | ||
"vcam.SetFocalPoint( [-0.017, 0.11, -0.001] )\n", | ||
"vcam.SetViewUp( [0.0, 1.0, 0.0] )\n", | ||
"vcam.SetDistance( 0.4 )\n", | ||
"k3dcam = vtkCameraToK3D(vcam)\n", | ||
"printc('k3dcam is', k3dcam)\n", | ||
"\n", | ||
"settings.notebook_plotter.camera = k3dcam" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.