class
aicafe.Snake (PointSet)
This class represents a curve in a 3D space. The curve is constituted by a series of sequentially connected points, and is thus named a snake. A snake can have some additional attributes for the whole point set (e.g., snake type) or for each point (e.g., radius at each point).
Snake is a subclass of PointSet. While a point set consists of points on a regular grid,
Snake forces the points to have a 1D shape, i.e., the point set representing a snake should have a shape of
[P, 3], where [P] indicates the number of points in the snake.
To initialize a snake, see __new__() below.
__new__(cls, array, type=None, radii=None)
To initialize a snake, simply generate a point set or an
ArrayLike data
structure that can initialize a point set, then pass it to Snake().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ArrayLike
|
A point set to initialize the snake, or an array to initialize the point set that represents the snake. |
required |
type
|
int
|
The snake type represented by an integer. If |
None
|
radii
|
Sequence[float]
|
The radii of points in the snake. If |
None
|
Returns:
| Type | Description |
|---|---|
Snake
|
Initialized snake. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
length(self)
lengths_cum(self)
Cumulative lengths of self.
Returns:
| Type | Description |
|---|---|
NDArray
|
Shape of [P], where \(P\) is the number of points on self. The \(i\)-th element is the length of the curve consisting of the first \(i\) points on self. Particularly, the \(0\)-th element is \(0\). |
resample(self, step=None)
Resample points on the curve so that the points are equidistant. The first and last points will be the same.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
the fixed distance between two consecutive points after resampling. |
None
|
Return
(Snake): The resampled snake. The radius at each point will also be interpolated if not None.