-
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
20 changed files
with
293 additions
and
44 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 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,16 @@ | ||
""" | ||
Computes the (signed) distance | ||
from one mesh to another. | ||
""" | ||
from vtkplotter import Sphere, Cube, show, Text | ||
|
||
s1 = Sphere() | ||
s2 = Cube(pos=[1,0,0], c='white', alpha=0.4) | ||
|
||
s1.distanceToMesh(s2, signed=True, negate=False) | ||
|
||
s1.addScalarBar(title='Signed\nDistance') | ||
|
||
#print(s1.scalars("Distance")) | ||
|
||
show(s1, s2, Text(__doc__)) |
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,19 @@ | ||
''' | ||
Voronoi in 3D with Voro++ library. | ||
''' | ||
from vtkplotter import voronoi3D, Points, show | ||
import numpy as np | ||
|
||
N = 2000 | ||
nuclei = np.random.rand(N, 3) - (0.5,0.5,0.5) | ||
ncl = Points(nuclei).clean(0.1) # clean makes points evenly spaced | ||
nuclei = ncl.coordinates() | ||
|
||
actor = voronoi3D(nuclei, tol=.001) | ||
#print(len(actor.info['cells']), actor.info['volumes']) | ||
|
||
pts_inside = actor.insidePoints(nuclei) | ||
inpts = Points(pts_inside, r=50, c='r', alpha=0.2) | ||
|
||
show(actor, inpts) | ||
|
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,43 @@ | ||
''' | ||
Visualize the phase space of a simple pendulum. | ||
x = starting angle theta | ||
y = starting angular velocity | ||
''' | ||
# From https://www.youtube.com/watch?v=p_di4Zn4wz4 | ||
# Overview of differential equations | Chapter 1 | ||
# (by 3Blue1Brown) | ||
|
||
#Install with: | ||
# pip install vtkplotter | ||
|
||
from vtkplotter import * | ||
|
||
# Physical constants | ||
g = 9.81 # m/s^2 | ||
L = 2 # m | ||
mu = 0.1 # friction 1/s | ||
delta_t = 0.01 # Some time step | ||
t_tot = 50 # seconds total time | ||
|
||
# Definition of ODE | ||
def get_theta_dot_dot(theta, theta_dot): | ||
return -mu * theta_dot - (g/L) * sin(theta) | ||
|
||
lines = [] | ||
for THETA_0 in arange(0, 3.1415, 0.2): | ||
for THETA_DOT_0 in arange(4, 9, 1): | ||
|
||
# Solution to the differential equation | ||
theta = THETA_0 | ||
theta_dot = THETA_DOT_0 | ||
pts = [] | ||
for time in arange(0, t_tot, delta_t): | ||
theta_dot_dot = get_theta_dot_dot(theta, theta_dot) | ||
theta += theta_dot * delta_t | ||
theta_dot += theta_dot_dot * delta_t | ||
pts.append([theta, theta_dot]) | ||
|
||
l = Line(pts).color(int(THETA_DOT_0)) | ||
lines.append(l) | ||
|
||
show(lines, Text(__doc__), axes=2, bg='white') |
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 |
---|---|---|
|
@@ -46,7 +46,7 @@ | |
__email__ = "[email protected]" | ||
__status__ = "dev" | ||
__website__ = "https://github.com/marcomusy/vtkplotter" | ||
__version__ = "2019.1.2" ### defined also above, in setup.py and docs/source/conf.py | ||
__version__ = "2019.1.3" ### defined also above, in setup.py and docs/source/conf.py | ||
|
||
from vtkplotter.plotter import * | ||
from vtkplotter.analysis import * | ||
|
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.