Esempio n. 1
0
def fit_plane_to_points(points, return_meta=False):
    """
    Fits a plane to a set of points

    Parameters
    ----------
    points : np.ndarray
        Size n by 3 array of points to fit a plane through

    return_meta : bool
        If true, also returns the center and normal used to generate the plane
    """
    data = np.array(points)
    center = data.mean(axis=0)
    result = np.linalg.svd(data - center)
    normal = np.cross(result[2][0], result[2][1])
    plane = vtki.Plane(center=center, direction=normal)
    if return_meta:
        return plane, center, normal
    return plane
Esempio n. 2
0
def test_plane():
    surf = vtki.Plane()
    assert np.any(surf.points)
    assert np.any(surf.faces)
Esempio n. 3
0
"""
# sphinx_gallery_thumbnail_number = 3
import vtki

plotter = vtki.Plotter()
actor = plotter.add_mesh(vtki.Sphere())
plotter.remove_actor(actor)
plotter.show()


################################################################################
# Clearing the entire plotting window:

plotter = vtki.Plotter()
plotter.add_mesh(vtki.Sphere())
plotter.add_mesh(vtki.Plane())
plotter.clear()  # clears all actors
plotter.show()


################################################################################
# Or you can give any actor a ``name`` when adding it and if an actor is added
# with that same name at a later time, it will replace the previous actor:

plotter = vtki.Plotter()
plotter.add_mesh(vtki.Sphere(), name='mydata')
plotter.add_mesh(vtki.Plane(), name='mydata')
# Only the Plane is shown!
plotter.show()
Esempio n. 4
0
~~~~~~~~~~~~~~~~~

The "Hello, world!" of VTK
"""
import vtki

################################################################################
# This runs through several of the available geomoetric objects available in VTK
# which ``vtki`` provides simple conveinance methods for generating.
#
# Let's run through creating a few geometric objects!

cyl = vtki.Cylinder()
arrow = vtki.Arrow()
sphere = vtki.Sphere()
plane = vtki.Plane()
line = vtki.Line()
box = vtki.Box()
cone = vtki.Cone()
poly = vtki.Polygon()
disc = vtki.Disc()

################################################################################
# Now let's plot them all in one window

p = vtki.Plotter(shape=(3, 3))
# Top row
p.subplot(0,0)
p.add_mesh(cyl, color='tan', show_edges=True)
p.subplot(0,1)
p.add_mesh(arrow, color='tan', show_edges=True)