Vector2D
A vector in 2D space. Used for directions, positions, or scalar-like 2D values. Supports to_list() and to_numpy(). This datatype is used across the Telekinesis ecosystem for 2D vector data.
Field
Required
| Field | Type | Description |
|---|---|---|
xy | ArrayLike | 2D vector; shape (2,), dtype float32. |
Optional
None.
Methods
| Method | Description |
|---|---|
to_list() | Returns a Python list of 2 floats: [x, y]. |
to_numpy() | Returns a NumPy array of shape (2,), dtype float32. |
Example
From the datatypes examples:
python
import numpy as np
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create Vector2D instance
# ------------------------------------------------
xy = np.array([1.0, 2.0], dtype=np.float32)
vec_2d = datatypes.Vector2D(xy)
# ------------------------------------------------
# 2. Access data via to_list and to_numpy
# ------------------------------------------------
data_list = vec_2d.to_list()
logger.info("Vector2D to_list x={}", data_list[0])
logger.info("Vector2D to_list y={}", data_list[1])
logger.info("Vector2D to_numpy shape={}", vec_2d.to_numpy().shape)
