Commit b1841131 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

added ball method for tfields.Points3D

parent e588f303
......@@ -7,6 +7,7 @@ Mail:
basic threedimensional tensors
import tfields
import numpy as np
class Points3D(tfields.Tensors):
......@@ -138,6 +139,26 @@ class Points3D(tfields.Tensors):
kwargs['dim'] = 3
return super(Points3D, cls).__new__(cls, tensors, **kwargs)
def balls(self, radius, spacing=(5, 3)):
Buils a sphere around each point with resolution
radius (float): radius of spheres
spacing (tuple of int): n_phi, n_theta
sphere = tfields.Mesh3D.grid((radius, radius, 1),
(-np.pi, np.pi, spacing[0]),
(-np.pi / 2, np.pi / 2, spacing[1]),
balls = []
with self.tmp_transform('cartesian'):
for point in self:
ball = sphere.copy()
ball += point
return tfields.Mesh3D.merged(*balls)
if __name__ == '__main__': # pragma: no cover
import doctest
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment