Skip to content
Projects

Cone

Download notebookView on GitHubRun when the site was built.

A cone or a frustum along any axis: nozzles, tips and tapered electrodes.

Cone(start, end, start_radius, end_radius) has radius start_radius at start and end_radius at end; one of them may be zero, which puts the tip there. The level set is the exact signed distance.

import numpy as np
from simgeometry import Cone, GeometryCollection
tip = Cone(start=(0.0, 0.0, 0.0), end=(0.0, 0.0, 1.0), start_radius=0.5, end_radius=0.0)
frustum = Cone(
start=(1.5, 0.0, 0.0), end=(1.5, 0.0, 1.0), start_radius=0.5, end_radius=0.25
)
print("volumes:", round(tip.volume(), 4), round(frustum.volume(), 4))
print("distance from the tip:", tip.signed_distance((0.0, 0.0, 1.5)))
assert np.isclose(tip.volume(), np.pi * 0.5**2 / 3)
assert np.isclose(tip.signed_distance((0.0, 0.0, 1.5)), 0.5)
volumes: 0.2618 0.4581
distance from the tip: 0.5
import plasma_plots
import pyvista as pv
pv.OFF_SCREEN = True # render without a window, e.g. on a docs server
cones = GeometryCollection({"cone": tip, "frustum": frustum})
plotter = cones.show_3d(
backend="pyvista", display=False, resolution=64, show_bounds=False
)
plasma_plots.scene(plotter, alt="A cone and a frustum side by side")
A cone and a frustum side by side
Open in a new tab