TargetGrid¶
ferreus_bbfmm.TargetGrid(origin, spacing, shape)
¶
Represents a regular grid of target points in one, two, or three dimensions.
Stores only the origin, spacing, and number of samples on each axis. Target coordinates are calculated in C order, with the last axis varying fastest.
Constructs a regular target grid from axis origins, spacing, and sample counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
list[float]
|
Coordinate of the first sample on each axis. |
required |
spacing
|
list[float]
|
Non-negative spacing on each axis. Zero spacing is allowed only for axes with one sample. |
required |
shape
|
list[int]
|
Positive number of samples on each axis. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the arrays do not describe one to three axes, the coordinates or spacing are invalid, or the total number of target points exceeds the supported index range. |
OverflowError
|
If a sample count is negative or exceeds the supported index range. |
from_spacing(extents, spacing)
staticmethod
¶
Constructs a regular target grid from bounding extents and axis spacing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extents
|
list[float]
|
Bounding box |
required |
spacing
|
list[float]
|
Positive spacing on each axis. |
required |
Returns:
| Type | Description |
|---|---|
TargetGrid
|
A grid beginning at the lower bounds and containing all samples up to the upper bounds. The given spacing is preserved, so the final sample may fall short of the upper bound. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the bounds, spacing, or resulting sample counts are invalid. |
dimensions()
¶
Gets the number of grid axes.
shape()
¶
Gets the number of samples on each grid axis.
point_count()
¶
Calculates the total number of grid targets as the product of the axis sample counts.
coordinate(target_index, axis)
¶
Calculates a single coordinate of a grid target for the given axis.
The target index uses C order, with the last axis varying fastest.
Raises:
| Type | Description |
|---|---|
IndexError
|
If the target index or axis is out of bounds. |
OverflowError
|
If the target index or axis is negative or exceeds the supported index range. |
write_target(target_index, output)
¶
Calculates the coordinates of a grid target and writes them to the given output array.
The target index uses C order, with the last axis varying fastest. The output must be a writable one-dimensional float64 array.
Raises:
| Type | Description |
|---|---|
IndexError
|
If the target index is out of bounds. |
ValueError
|
If the output length differs from the dimensionality. |
OverflowError
|
If the target index is negative or exceeds the supported index range. |
extents()
¶
Gets the bounding extents of the sampled grid.
Returns [xmin, ymin, ..., xmax, ymax, ...] using the first and last samples on each axis,
before any tree padding or coordinate transforms.
points(start, count)
¶
Creates a matrix containing a contiguous range of grid target coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
int
|
Global index of the first target in C order. |
required |
count
|
int
|
Number of consecutive targets to include. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A target point array of shape (count, D), where D is the dimensionality. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the requested range extends beyond the grid targets. |
OverflowError
|
If start or count is negative or exceeds the supported index range. |