def Cone(center=(0., 0., 0.), direction=(1., 0., 0.), height=1.0, radius=None, capping=True, angle=None, resolution=6): """Create a cone. Parameters ---------- center : np.ndarray or list Center in [x, y, z]. Middle of the axis of the cone. direction : np.ndarray or list Direction vector in [x, y, z]. Orientation vector of the cone. height : float Height along the cone in its specified direction. radius : float Base radius of the cone. capping : bool Turn on/off whether to cap the base of the cone with a polygon. angle : float The angle in degrees between the axis of the cone and a generatrix. resolution : int Number of facets used to represent the cone. """ src = _vtk.vtkConeSource() src.SetCapping(capping) src.SetDirection(direction) src.SetCenter(center) src.SetHeight(height) # Contributed by @kjelljorner in #249: if angle and radius: raise ValueError( "Both radius and angle specified. They are mutually exclusive.") elif angle and not radius: src.SetAngle(angle) elif not angle and radius: src.SetRadius(radius) elif not angle and not radius: src.SetRadius(0.5) src.SetResolution(resolution) src.Update() return pyvista.wrap(src.GetOutput())
def Cone(center=(0., 0., 0.), direction=(1., 0., 0.), height=1.0, radius=None, capping=True, angle=None, resolution=6): """Create a cone. Parameters ---------- center : iterable, optional Center in ``[x, y, z]``. Axis of the cone passes through this point. direction : iterable, optional Direction vector in ``[x, y, z]``. Orientation vector of the cone. height : float, optional Height along the cone in its specified direction. radius : float, optional Base radius of the cone. capping : bool, optional Enable or disable the capping the base of the cone with a polygon. angle : float, optional The angle in degrees between the axis of the cone and a generatrix. resolution : int, optional Number of facets used to represent the cone. Returns ------- pyvista.PolyData Cone mesh. Examples -------- Create a default Cone. >>> import pyvista >>> mesh = pyvista.Cone() >>> mesh.plot(show_edges=True, line_width=5) """ src = _vtk.vtkConeSource() src.SetCapping(capping) src.SetDirection(direction) src.SetCenter(center) src.SetHeight(height) if angle and radius: raise ValueError( "Both radius and angle specified. They are mutually exclusive.") elif angle and not radius: src.SetAngle(angle) elif not angle and radius: src.SetRadius(radius) elif not angle and not radius: src.SetRadius(0.5) src.SetResolution(resolution) src.Update() return pyvista.wrap(src.GetOutput())