-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshapes.py
592 lines (552 loc) · 25.3 KB
/
shapes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
#!/usr/bin/env python
'''
Created on 1 Oct 2020
@author: Christoph Minz
@license: BSD 3-Clause
'''
from __future__ import annotations
from typing import List, Dict, Tuple, Any, Union, Optional
import math
import numpy as np
from matplotlib import patches
from matplotlib.pyplot import gca
from matplotlib.axes import Axes
from matplotlib.patches import Patch
default_samplingsize: int = 128 # default number of edges for curved objects
class CoordinateShape(object):
'''
Handles a coordinate shape for embedding (and sprinkling) regions.
'''
_dim: int
_name: str
_center: np.ndarray
_params: Dict[str, Any]
_volume: float
def __init__(self, dim: int, name: str, **kwargs) -> None:
'''
Sets the embedding shape, but does not adjust event coordinates.
The dimension parameter dim must be an integer greater than zero.
Accepted shape names (and parameters)
-------------------------------------
'ball' ('radius': float, default: 1.0, must be > 0.0,
'hollow': float, default: 0.0, must be >= 0.0 and < 1.0)
Ball shape in all spacetime coordinates. The parameter 'hollow' is
the fraction (between 0.0 and 1.0) of the radius of the ball to
give an empty interior.
'bicone' ('radius': float, default: 1.0, must be > 0.0,
'hollow': float, default: 0.0, must be >= 0.0 and < 1.0)
Ball shape in all space coordinates and conical to the past and
future. The parameter 'hollow' is the fraction (between 0.0 and
1.0) of the radius of the bicone to give an empty interior.
(alternative shape name: 'diamond')
'cylinder' ('radius': float, default: 1.0, must be > 0.0,
'duration': float, default: 2.0 * radius, must be > 0.0,
'hollow': float, default: 0.0, must be >= 0.0 and < 1.0)
Ball shape in all space coordinates and straight along the time
coordinate for the length 'duration'. The parameter 'hollow' is
the fraction (between 0.0 and 1.0) of the radius and duration of
the cylinder to give an empty interior.
'cube' ('edge': float, default: 1.0, must be > 0.0)
Cube shape with the same edge length 'edge' in all spacetime
coordinates.
'cuboid' ('edges': Iterable[float], default: [1.0, 1.0, ...],
must all be > 0.0)
Cuboid shape with distinct edge lengths 'edges' in the respective
spacetime coordinates. The default edges yield a cube.
All shapes have a further keyword argument, 'center' (Iterable[float])
to specify the central point, with the zero vector as default value.
Raises a ValueError if some input value is invalid.
'''
# set dimension:
if dim < 1:
raise ValueError('The value ''dim'' is out of range. ' +
'It must be an integer of at least 1.')
self._dim = dim
# set name:
if name == 'diamond':
name = 'bicone'
elif name not in ['ball', 'bicone', 'cylinder',
'cube', 'cuboid']:
raise ValueError('A shape with name ''' +
f'{name}'' is not supported.')
self._name = name
# set centre point:
try:
self._center = np.array(kwargs['center'], dtype=np.float32)
if self._center.shape != (dim,):
raise TypeError
except KeyError:
self._center = np.zeros(dim, dtype=np.float32)
except TypeError:
raise ValueError('The value for the key ''center'' has to be ' +
f'an Iterable of {dim} float values.')
def param_rangecheck(p: str, maxValue: float = math.nan,
canBeZero: bool = False):
isTooLow: bool = (canBeZero and (self._params[p] < 0.0)) or \
(not canBeZero and self._params[p] <= 0.0)
errorStr: str = 'greater than or equal to 0' if canBeZero else \
'greater than 0'
if math.isnan(maxValue):
if isTooLow:
raise ValueError('The parameter ''' +
f'{p}'' is out of range. ' +
f'It must be a float {errorStr}.')
elif isTooLow or (self._params[p] >= maxValue):
raise ValueError('The parameter ''' +
f'{p}'' is out of range. ' +
f'It must be a float {errorStr} and '
f'smaller than {maxValue}.')
# set shape parameters:
value: float
self._params = {}
if name in {'ball', 'bicone', 'cylinder'}:
self._params['radius'] = np.array(kwargs.get('radius', 1.0),
dtype=np.float32)
param_rangecheck('radius')
self._params['hollow'] = np.array(kwargs.get('hollow', 0.0),
dtype=np.float32)
param_rangecheck('hollow', 1.0, True)
if name == 'cylinder':
self._params['duration'] = np.array(
kwargs.get('duration', 2.0 * self._params['radius']),
dtype=np.float32)
param_rangecheck('duration')
elif name == 'cube':
self._params['edge'] = np.array(kwargs.get('edge', 1.0),
dtype=np.float32)
param_rangecheck('edge')
elif name == 'cuboid':
self._params['edges'] = np.array(
kwargs.get('edges', np.ones((dim,))), dtype=np.float32)
if self._params['edges'].shape != (dim,):
raise ValueError('The value for the key "edges" has ' +
f'to be an Iterable of {dim} float values.')
if any(x <= 0.0 for x in self._params['edges']):
raise ValueError('At least one edge length is out of range.' +
'Each must be a float greater than 0.')
def __str__(self):
if ('hollow' in self._params) and \
(self._params['hollow'] > 0.0):
return f'hollow {self._dim}-{self._name}'
else:
return f'{self._dim}-{self._name}'
def __repr__(self):
return f'{self._class__._name__}(' + \
f'{self._dim}, {self._name}, center={self._center}, ' + \
f'**{self._params})'
@property
def Dim(self) -> int:
'''
Returns the dimension of the spacetime (region).
'''
return self._dim
@property
def Name(self) -> str:
'''
Returns the shape name of the spacetime region.
'''
return self._name
@property
def Center(self) -> np.ndarray:
'''
Returns the shape center of the spacetime region.
'''
return self._center
def Parameter(self, key: str) -> Any:
'''
Returns a parameter for the shape of the spacetime region.
'''
return self._params[key]
@property
def Volume(self) -> float:
'''
Returns the volume of the shape.
(On the first call of this property, the volume is computed and stored
in an internal variable.)
'''
if not hasattr(self, '_volume'):
V: float = 0.0
r: float = self._params.get('radius', 0.0)
isHollow: bool = self._params.get('hollow', 0.0) > 0.0
if self._name == 'ball':
V = r**self._dim
if isHollow:
V -= (self._params['hollow'] * r)**self._dim
V *= math.pi**(self._dim / 2.0) / \
math.gamma(self._dim / 2.0 + 1.0)
elif self._name == 'cylinder':
V = r**(self._dim - 1)
if isHollow:
V -= (self._params['hollow'] * r)**(self._dim - 1)
V *= math.pi**(self._dim / 2.0 - 0.5) / \
math.gamma(self._dim / 2.0 + 0.5)
V *= self._params['duration']
elif self._name == 'bicone':
V = r**self._dim
if isHollow:
V -= (self._params['hollow'] * r)**self._dim
V *= math.pi**(self._dim / 2.0 - 0.5) / \
math.gamma(self._dim / 2.0 + 0.5)
V *= 2.0 / self._dim
elif self._name == 'cube':
V = self._params['edge']**self._dim
elif self._name == 'cuboid':
V = math.prod(self._params['edges'])
self._volume = V
return self._volume
def MaxEdgeHalf(self, dims: List[int]) -> float:
'''
Returns the half of the largest shape edge of the spacetime region.
'''
if self.Name == 'cube':
return self._params['edge'] / 2
elif self.Name in {'bicone', 'ball'}:
return self._params['radius']
elif self.Name == 'cylinder':
if dims.count(0) > 0:
return max([self._params['radius'],
self._params['duration'] / 2])
else:
return self._params['radius']
else: # cuboid
return max(self._params['edges'][dims]) / 2
def Limits(self, dim: int) -> Tuple[float, float]:
'''
Returns a tuple of floats for the minimum (left) and maximum (right)
of a shape along coordinate dimension 'dim' (0-indexed).
'''
if (dim < 0) or (dim >= self.Dim):
raise ValueError('The argument d is out of range, ' +
f'{dim} not in [0, {self.Dim}).')
if (dim == 0) and (self.Name == 'cylinder'):
l = self._params['duration'] / 2
elif self.Name == 'cube':
l = self._params['edge'] / 2
elif self.Name == 'cuboid':
l = self._params['edges'][dim] / 2
else:
l = self._params['radius']
shift: float = self._center[dim]
return (-l + shift, l + shift)
def plot(self, dims: List[int], plotAxes: Optional[Axes] = None,
**kwargs) -> Union[Patch,
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]]:
'''
Plots a cut through the center of the shape showing `dims` that
can be a list of 2 integers (for a 2D plot) or 3 integers (for a 3D
plot). The argument `plotAxes` specifies the plot axes object to be
used (by default the current axes of `matplotlib`).
As optional keyword arguments, the plotting options can be specified
that will overwrite the defaults that are for 2D:
{'edgecolor': 'black', 'facecolor': 'black', 'alpha': 0.05}
and for 3D:
{'edgecolor': None, 'color': 'black', 'alpha': 0.05}
The plotting options are passed to the Poly3DCollection object if it
is plotting in 3D or to the Patch object if it is plotting in 2D.
The Patch object is returned for a 2D plot and a list of surfaces is
returned for a 3D plot.
'''
is3d: bool = len(dims) == 3
if plotAxes is None:
plotAxes = gca(projection='3d') if is3d else \
gca(projection=None)
if is3d:
plotoptions = {'edgecolor': None,
'color': 'black',
'alpha': 0.05}
else:
plotoptions = {'edgecolor': 'black',
'facecolor': 'black',
'alpha': 0.05}
plotoptions.update(kwargs)
timeaxis: int
try:
timeaxis = dims.index(0)
except ValueError:
timeaxis = -1
hollow: float = 0.0
if 'hollow' in self._params:
hollow = self._params['hollow']
if is3d:
S: List[Tuple[np.ndarray, np.ndarray, np.ndarray]]
r: float
if self.Name == 'cube':
S = CubeSurface(self.Center[dims],
self._params['edge'])
elif self.Name == 'ball' or \
((timeaxis < 0) and (self.Name in {'bicone', 'cylinder'})):
r = self._params['radius']
S = BallSurface(self.Center[dims], r)
if hollow > 0.0:
S = BallSurface(self.Center[dims],
hollow * r) + S
elif self.Name == 'cylinder':
r = self._params['radius']
h: float = self._params['duration']
S = CylinderSurface(self.Center[dims],
r, h, hollow, timeaxis)
elif self.Name == 'bicone':
r = self._params['radius']
conecenter: np.ndarray = self.Center[dims]
tip: np.ndarray = conecenter.copy()
top: np.ndarray = conecenter.copy()
tip[timeaxis] = conecenter[timeaxis] - r
top[timeaxis] = conecenter[timeaxis] + r
S = OpenConeSurface(tip, r, r, timeaxis) + \
OpenConeSurface(top, r, -r, timeaxis)
if hollow > 0.0:
r *= hollow
tip[timeaxis] = conecenter[timeaxis] - r
top[timeaxis] = conecenter[timeaxis] + r
S = OpenConeSurface(tip, r, r, timeaxis) + \
OpenConeSurface(top, r, -r, timeaxis) + S
else: # cuboid
S = CuboidSurface(self.Center[dims],
self._params['edges'][dims])
for XYZ in S:
plotAxes.plot_surface(*XYZ, **plotoptions)
return S
else:
p: Patch
a: float
b: float
if self.Name == 'cube':
a = self._params['edge']
p = patches.Rectangle(
self.Center[dims] - 0.5 * np.array([a, a]), width=a,
height=a, **plotoptions)
elif self.Name == 'ball' or \
((timeaxis < 0) and (self.Name in {'bicone', 'cylinder'})):
if hollow == 0.0:
p = patches.Circle(
self.Center[dims], self._params['radius'],
**plotoptions)
else:
p = patches.Polygon(
CircleEdge(self.Center[dims], self._params['radius'],
hollow),
**plotoptions)
elif self.Name == 'cylinder':
cyl: np.ndarray = CylinderCutEdge(
self.Center[dims], self._params['radius'],
self._params['duration'], hollow)
if timeaxis == 0:
cyl = cyl[:, [1, 0]]
p = patches.Polygon(cyl, **plotoptions)
elif self.Name == 'bicone':
p = patches.Polygon(
BiconeEdge(self.Center[dims], self._params['radius'],
hollow),
**plotoptions)
else: # cuboid
edges: np.ndarray = self._params['edges'][dims]
p = patches.Rectangle(
self.Center[dims] - 0.5 * edges, width=edges[0],
height=edges[1], **plotoptions)
plotAxes.add_patch(p)
return p
def RectangleEdge(left: float, bottom: float, width: float, height: float) -> \
np.ndarray:
'''
Returns a matrix of size 5 x 2 that describes the edge of a rectangle.
'''
return np.array([[left, bottom],
[left + width, bottom],
[left + width, bottom + height],
[left, bottom + height],
[left, bottom]])
def CircleEdge(center: np.ndarray, radius: float, hollow: float = 0.0,
samplingsize: int = -1) -> np.ndarray:
'''
Returns a matrix of size m x 2 that describes the edge of a circle.
If the circle is hollow, `m = 2 * samplingsize + 3`, else it is
`samplingsize + 1`, where `samplingsize` is set to `default_samplingsize`
if non-positive.
'''
if samplingsize <= 0:
samplingsize = default_samplingsize
samplingsize = samplingsize + 1
edge: np.ndarray = np.empty((samplingsize if hollow == 0.0
else 2 * samplingsize + 1, 2))
phi = np.linspace(0.0, 2.0 * np.pi, samplingsize)
edge[:samplingsize, 0] = center[0] + radius * np.cos(phi)
edge[:samplingsize, 1] = center[1] + radius * np.sin(phi)
if hollow > 0.0:
edge[samplingsize, :] = np.array([[np.nan, np.nan]])
edge[(samplingsize + 1):, 0] = center[0] + \
hollow * radius * np.cos(-phi)
edge[(samplingsize + 1):, 1] = center[1] + \
hollow * radius * np.sin(-phi)
return edge
def EllipseEdge(center: np.ndarray, radii: np.ndarray, hollow: float = 0.0,
samplingsize: int = -1) -> np.ndarray:
'''
Returns a matrix of size m x 2 that describes the edge of an ellipse.
If the ellipse is hollow, `m = 2 * samplingsize + 3`, else it is
`samplingsize + 1`, where `samplingsize` is set to `default_samplingsize`
if non-positive.
'''
if samplingsize <= 0:
samplingsize = default_samplingsize
samplingsize = samplingsize + 1
edge: np.ndarray = np.empty((samplingsize if hollow == 0.0
else 2 * samplingsize + 1, 2))
phi = np.linspace(0.0, 2.0 * np.pi, samplingsize)
edge[:samplingsize, 0] = center[0] + radii[0] * np.cos(phi)
edge[:samplingsize, 1] = center[1] + radii[1] * np.sin(phi)
if hollow > 0.0:
edge[samplingsize, :] = np.array([[np.nan, np.nan]])
edge[(samplingsize + 1):, 0] = center[0] + \
hollow * radii[0] * np.cos(-phi)
edge[(samplingsize + 1):, 1] = center[1] + \
hollow * radii[1] * np.sin(-phi)
return edge
def BiconeEdge(center: np.ndarray, radius: float, hollow: float = 0.0) -> \
np.ndarray:
'''
Returns a matrix of size m x 2 that describes the edge of a 2D bicone.
If the bicone is hollow, `m = 11`, else it is `5`.
'''
edge: np.ndarray = np.array([[center[0], center[1] + radius],
[center[0] - radius, center[1]],
[center[0], center[1] - radius],
[center[0] + radius, center[1]],
[center[0], center[1] + radius]])
if hollow > 0.0:
radius = hollow * radius
edge = np.concatenate(
(edge, np.array([[np.nan, np.nan]]),
np.array([[center[0] + radius, center[1]],
[center[0], center[1] - radius],
[center[0] - radius, center[1]],
[center[0], center[1] + radius],
[center[0] + radius, center[1]]])))
return edge
def CylinderCutEdge(center: np.ndarray, radius: float, height: float,
hollow: float = 0.0) -> np.ndarray:
'''
Returns a matrix of size m x 2 that describes the (x, z) coordinates
of the edge of the y=0 cut through a cylinder aligned along the z-axis.
If the cylinder is hollow, `m = 11`, else it is `5`.
'''
height_half: float = height / 2
if hollow == 0.0:
return RectangleEdge(center[0] - radius, center[1] - height_half,
2 * radius, height)
else:
return np.concatenate(
(RectangleEdge(center[0] - radius, center[1] - height_half,
(1 - hollow) * radius, height),
np.array([[np.nan, np.nan]]),
RectangleEdge(center[0] + hollow * radius, center[1] - height_half,
(1 - hollow) * radius, height)))
def CuboidSurface(center: np.ndarray, edges: np.ndarray) -> \
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]:
'''
Returns the XYZ data that describes a cuboid surface.
Each data matrix has size `5` x `4`.
'''
xed: float = edges[0]
yed: float = edges[1]
zed: float = edges[2]
corner: np.ndarray = center - edges / 2
S: List[Tuple[np.ndarray, np.ndarray, np.ndarray]] = []
S.append((np.array([[0.0]]) + corner[0],
np.array([[0.0, 0.0, yed, yed]]) + corner[1],
np.array([[0.0, zed, zed, 0.0]]).transpose() + corner[2]))
S.append((np.array([[0.0, xed, xed, 0.0]]).transpose() + corner[0],
np.array([[0.0]]) + corner[1],
np.array([[0.0, 0.0, zed, zed]]) + corner[2]))
S.append((np.array([[0.0, 0.0, xed, xed]]) + corner[0],
np.array([[0.0, yed, yed, 0.0]]).transpose() + corner[1],
np.array([[0.0]]) + corner[2]))
S.append((np.array([[xed]]) + corner[0],
np.array([[0.0, yed, yed, 0.0]]) + corner[1],
np.array([[0.0, 0.0, zed, zed]]).transpose() + corner[2]))
S.append((np.array([[0.0, 0.0, xed, xed]]).transpose() + corner[0],
np.array([[yed]]) + corner[1],
np.array([[0.0, zed, zed, 0.0]]) + corner[2]))
S.append((np.array([[0.0, xed, xed, 0.0]]) + corner[0],
np.array([[0.0, 0.0, yed, yed]]).transpose() + corner[1],
np.array([[zed]]) + corner[2]))
return S
def CubeSurface(center: np.ndarray, edge: float) -> \
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]:
'''
Returns a `CuboidSurface` object with the same `edge` length in all
dimensions.
'''
return CuboidSurface(center, np.array([edge, edge, edge]))
def BallSurface(center: np.ndarray, radius: float, samplingsize: int = -1) -> \
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]:
'''
Returns the XYZ data that describes a ball surface.
Each data matrix has size `samplingsize + 1` x `(samplingsize + 1)/2`,
where `samplingsize` is set to `default_samplingsize` if non-positive.
'''
if samplingsize <= 0:
samplingsize = default_samplingsize
samplingsize = samplingsize + 1
phi: np.ndarray = np.linspace(0.0, 2.0 * np.pi, samplingsize)
theta: np.ndarray = np.linspace(0.0, np.pi, round(samplingsize / 2))
return [(np.outer(np.cos(phi), np.sin(theta)) * radius + center[0],
np.outer(np.sin(phi), np.sin(theta)) * radius + center[1],
np.outer(np.ones(samplingsize), np.cos(theta)) * radius
+ center[2])]
def CylinderSurface(center: np.ndarray, radius: float, height: float,
hollow: float = 0.0, zaxis: int = 2,
samplingsize: int = -1) -> \
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]:
'''
Returns the XYZ data that describes a (hollow) cylinder surface.
Each data matrix has size `4` x `samplingsize + 1` if `hollow == 0.0`,
or `5` x `samplingsize + 1` if `1.0 > hollow > 0.0`, where
`samplingsize` is set to `default_samplingsize` if non-positive.
'''
if samplingsize <= 0:
samplingsize = default_samplingsize
samplingsize = samplingsize + 1
phi: np.ndarray = np.linspace(0.0, 2.0 * np.pi, samplingsize)
radii: np.ndarray
relZ: np.ndarray
sampling: np.ndarray = np.ones(samplingsize)
if hollow == 0.0:
radii = radius * np.array([0.0, 1.0, 1.0, 0.0])
relZ = np.array([-sampling, -sampling, sampling, sampling])
else:
radii = radius * np.array([hollow, 1.0, 1.0, hollow, hollow])
relZ = np.array([-sampling, -sampling, sampling, sampling, -sampling])
XYZ: Tuple[np.ndarray, np.ndarray, np.ndarray] = \
(np.outer(radii, np.cos(phi)) + center[0],
np.outer(radii, np.sin(phi)) + center[1],
(height / 2) * relZ + center[2])
# rotate:
if zaxis == 0:
XYZ = (XYZ[2], XYZ[0], XYZ[1])
elif zaxis == 1:
XYZ = (XYZ[1], XYZ[2], XYZ[0])
return [XYZ]
def OpenConeSurface(tip: np.ndarray, radius: float, height: float,
zaxis: int = 2, samplingsize: int = -1) -> \
List[Tuple[np.ndarray, np.ndarray, np.ndarray]]:
'''
Returns the XYZ data that describes an open cone surface.
Each data matrix has size `2` x `samplingsize + 1`, where
`samplingsize` is set to `default_samplingsize` if non-positive.
'''
if samplingsize <= 0:
samplingsize = default_samplingsize
samplingsize = samplingsize + 1
phi: np.ndarray = np.linspace(0.0, 2.0 * np.pi, samplingsize)
radii: np.ndarray = radius * np.array([0.0, 1.0])
XYZ: Tuple[np.ndarray, np.ndarray, np.ndarray] = \
(np.outer(radii, np.cos(phi)) + tip[0],
np.outer(radii, np.sin(phi)) + tip[1],
np.array([np.zeros(samplingsize), np.ones(samplingsize)]) * height
+ tip[2])
# rotate:
if zaxis == 0:
XYZ = (XYZ[2], XYZ[0], XYZ[1])
elif zaxis == 1:
XYZ = (XYZ[1], XYZ[2], XYZ[0])
return [XYZ]