Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Boeckenhoff
tfields
Commits
b1841131
Commit
b1841131
authored
Dec 18, 2018
by
Daniel Boeckenhoff
Browse files
added ball method for tfields.Points3D
parent
e588f303
Changes
1
Hide whitespace changes
Inline
Side-by-side
tfields/points3D.py
View file @
b1841131
...
...
@@ -7,6 +7,7 @@ Mail: daniel.boeckenhoff@ipp.mpg.de
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
Args:
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
]),
coord_sys
=
'spherical'
)
sphere
.
transform
(
'cartesian'
)
balls
=
[]
with
self
.
tmp_transform
(
'cartesian'
):
for
point
in
self
:
ball
=
sphere
.
copy
()
ball
+=
point
balls
.
append
(
ball
)
return
tfields
.
Mesh3D
.
merged
(
*
balls
)
if
__name__
==
'__main__'
:
# pragma: no cover
import
doctest
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment