b64Vecs
See source codeTable of contents
Utilities for encoding and decoding points using base64 and Float16 encoding. Provides functions for converting between VecModel arrays and compact base64 strings, as well as individual point encoding/decoding operations.
class b64Vecs {}Methods
decodeFirstPoint( )
Get the first point from a delta-encoded base64 string. The first point is stored as Float32 for full precision.
static decodeFirstPoint(b64Points: string): null | VecModelParameters
| Name | Description |
|---|---|
| The delta-encoded base64 string |
Returns
null | VecModelThe first point as a VecModel, or null if the string is too short
decodeLastPoint( )
Get the last point from a delta-encoded base64 string. Requires decoding all points to accumulate deltas.
static decodeLastPoint(b64Points: string): null | VecModelParameters
| Name | Description |
|---|---|
| The delta-encoded base64 string |
Returns
null | VecModelThe last point as a VecModel, or null if the string is too short
decodePoints( )
Decode a delta-encoded base64 string back to an array of absolute VecModels. The first point is stored as Float32 (high precision), subsequent points are Float16 deltas that are accumulated to reconstruct absolute positions.
static decodePoints(base64: string): VecModel[]Parameters
| Name | Description |
|---|---|
| The base64-encoded string containing delta-encoded point data |
Returns
VecModel[]An array of VecModel objects with absolute coordinates
encodePoints( )
Encode an array of VecModels using delta encoding for improved precision. The first point is stored as Float32 (high precision for absolute position), subsequent points are stored as Float16 deltas from the previous point. This provides full precision for the starting position and excellent precision for deltas between consecutive points (which are typically small values).
Format: - First point: 3 Float32 values = 12 bytes = 16 base64 chars - Delta points: 3 Float16 values each = 6 bytes = 8 base64 chars each
static encodePoints(points: VecModel[]): stringParameters
| Name | Description |
|---|---|
| An array of VecModel objects to encode |
Returns
stringA base64-encoded string containing delta-encoded points