Documentation

Geometry, vectors, grids and graphs

Every operator a .lolo program can call, from the canonical registry the compiler bakes.

Namespaces on this page: geo/, graph/, grid/, vec/.

geo/

geo/aabb-overlap

Axis-aligned bounding box overlap test

lolo
1 (geo/aabb-overlap a b)

Parameters

NameTypeDescription
aobjectFirst bounding box
bobjectSecond bounding box

Returns: boolean

Example

lolo
1 (geo/aabb-overlap {"x":0,"y":0,"w":10,"h":10} {"x":5,"y":5,"w":10,"h":10}) // => true

geo/circle-overlap

Circle overlap test: distance(centers) <= a.r+b.r

lolo
1 (geo/circle-overlap a b)

Parameters

NameTypeDescription
aobjectFirst circle
bobjectSecond circle

Returns: boolean

Example

lolo
1 (geo/circle-overlap {"x":0,"y":0,"r":3} {"x":4,"y":0,"r":2}) // => true

geo/point-in-circle

Point containment in circle (inclusive)

lolo
1 (geo/point-in-circle point circle)

Parameters

NameTypeDescription
pointobjectPoint coordinates
circleobjectCircle (center and radius)

Returns: boolean

Example

lolo
1 (geo/point-in-circle {"x":1,"y":1} {"x":0,"y":0,"r":2}) // => true

geo/point-in-rect

Point containment in rect (inclusive bounds)

lolo
1 (geo/point-in-rect point rect)

Parameters

NameTypeDescription
pointobjectPoint coordinates
rectobjectRectangle bounds

Returns: boolean

Example

lolo
1 (geo/point-in-rect {"x":5,"y":5} {"x":0,"y":0,"w":10,"h":10}) // => true

geo/rect-circle-overlap

Rect-circle overlap via closest point on rect to circle center

lolo
1 (geo/rect-circle-overlap rect circle)

Parameters

NameTypeDescription
rectobjectRectangle bounds
circleobjectCircle (center and radius)

Returns: boolean

Example

lolo
1 (geo/rect-circle-overlap {"x":0,"y":0,"w":10,"h":10} {"x":12,"y":5,"r":3}) // => true

geo/reflect

Reflect vector v across normal n (assumed normalized)

lolo
1 (geo/reflect v n)

Parameters

NameTypeDescription
vobjectVector to reflect
nobjectSurface normal

Returns: vector

Example

lolo
1 (geo/reflect {"x":1,"y":-1} {"x":0,"y":1})

geo/segment-intersect

Intersection point of two segments, or null when parallel/none

lolo
1 (geo/segment-intersect seg1 seg2)

Parameters

NameTypeDescription
seg1arrayFirst segment endpoints
seg2arraySecond segment endpoints

Returns: point | null

Example

lolo
1 (geo/segment-intersect {"x1":0,"y1":0,"x2":4,"y2":4} {"x1":0,"y1":4,"x2":4,"y2":0})

graph/

graph/add-self-loops

Add self-loop edges to graph

lolo
1 (graph/add-self-loops graph)

Parameters

NameTypeDescription
graphobjectGraph to augment

Returns: graph

Example

lolo
1 (graph/add-self-loops ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

graph/batch

Batch multiple graphs into one

lolo
1 (graph/batch graphs)

Parameters

NameTypeDescription
graphsarrayGraphs to batch

Returns: graph

Example

lolo
1 (graph/batch [["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]]])

graph/degree

Get node degree tensor

lolo
1 (graph/degree graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: tensor

Example

lolo
1 (graph/degree ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

graph/edge-features

Get edge feature matrix

lolo
1 (graph/edge-features graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: tensor

Example

lolo
1 (graph/edge-features ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

graph/edge-index

Get edge index tensor

lolo
1 (graph/edge-index graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: tensor

Example

lolo
1 (graph/edge-index ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

graph/from-adjacency

Build graph from adjacency matrix and features

lolo
1 (graph/from-adjacency adjacency features)

Parameters

NameTypeDescription
adjacencyobjectAdjacency matrix
featuresobjectNode features

Returns: graph

Example

lolo
1 (graph/from-adjacency [[0,1],[1,0]] [[1.0],[2.0]])

graph/from-edge-list

Build graph from edge list and features

lolo
1 (graph/from-edge-list edges features)

Parameters

NameTypeDescription
edgesarrayEdge list
featuresobjectNode features

Returns: graph

Example

lolo
1 (graph/from-edge-list [[0,1]] [[1.0],[2.0]])

graph/from-entities

Build PyG graph from entity collections

lolo
1 (graph/from-entities entities)

Parameters

NameTypeDescription
entitiesarrayEntity collection

Returns: graph

Example

lolo
1 (graph/from-entities [{"age":30,"score":0.5},{"age":25,"score":0.7}])

graph/k-hop

K-hop neighborhood subgraph

lolo
1 (graph/k-hop graph nodeId k)

Parameters

NameTypeDescription
graphobjectGraph to traverse
nodeIdstringStarting node ID
knumberHop distance

Returns: graph

Example

lolo
1 (graph/k-hop ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]] 0 2)

graph/node-features

Get node feature matrix

lolo
1 (graph/node-features graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: tensor

Example

lolo
1 (graph/node-features ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

graph/num-edges

Get edge count

lolo
1 (graph/num-edges graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: number

Example

lolo
1 (graph/num-edges ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]]) // => 2

graph/num-nodes

Get node count

lolo
1 (graph/num-nodes graph)

Parameters

NameTypeDescription
graphobjectGraph to query

Returns: number

Example

lolo
1 (graph/num-nodes ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]]) // => 2

graph/subgraph

Extract subgraph by node mask

lolo
1 (graph/subgraph graph mask)

Parameters

NameTypeDescription
graphobjectGraph to subset
maskarrayNode selection mask

Returns: graph

Example

lolo
1 (graph/subgraph ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]] [true,false])

graph/to-undirected

Convert directed graph to undirected

lolo
1 (graph/to-undirected graph)

Parameters

NameTypeDescription
graphobjectDirected graph

Returns: graph

Example

lolo
1 (graph/to-undirected ["graph/from-adjacency",[[0,1],[1,0]],[[1.0],[2.0]]])

grid/

grid/cells-in-radius

All cells within Euclidean radius r (row-major order)

lolo
1 (grid/cells-in-radius center radius)

Parameters

NameTypeDescription
centerobjectCenter cell
radiusnumberEuclidean radius

Returns: array

Example

lolo
1 (grid/cells-in-radius {"x":0,"y":0} 1)

grid/distance

Chebyshev distance max(|dx|,|dy|)

lolo
1 (grid/distance a b)

Parameters

NameTypeDescription
aobjectFirst cell
bobjectSecond cell

Returns: number

Example

lolo
1 (grid/distance {"x":0,"y":0} {"x":3,"y":2}) // => 3

grid/from-world

World point to grid cell (floor)

lolo
1 (grid/from-world point cellSize)

Parameters

NameTypeDescription
pointobjectWorld coordinates
cellSizenumberCell size in world units

Returns: cell

Example

lolo
1 (grid/from-world {"x":80,"y":112} 32)

grid/in-bounds

Whether cell lies within a w×h grid

lolo
1 (grid/in-bounds cell width height)

Parameters

NameTypeDescription
cellobjectCell to check
widthnumberGrid width
heightnumberGrid height

Returns: boolean

Example

lolo
1 (grid/in-bounds {"x":2,"y":3} 5 5) // => true

grid/iso-to-screen

Isometric cell to screen point

lolo
1 (grid/iso-to-screen cell tileW tileH)

Parameters

NameTypeDescription
cellobjectIsometric cell
tileWnumberTile width
tileHnumberTile height

Returns: point

Example

lolo
1 (grid/iso-to-screen {"x":1,"y":0} 64 32)

grid/line

Bresenham line cells from a to b, inclusive, in step order

lolo
1 (grid/line a b)

Parameters

NameTypeDescription
aobjectStarting cell
bobjectEnding cell

Returns: array

Example

lolo
1 (grid/line {"x":0,"y":0} {"x":2,"y":2})

grid/manhattan-distance

Manhattan distance |dx|+|dy|

lolo
1 (grid/manhattan-distance p1 p2)

Parameters

NameTypeDescription
p1objectFirst point
p2objectSecond point

Returns: number

Example

lolo
1 (grid/manhattan-distance {"x":0,"y":0} {"x":3,"y":2}) // => 5

grid/neighbors

Adjacent cells in order N,E,S,W (+NE,SE,SW,NW if diagonal)

lolo
1 (grid/neighbors cell)

Parameters

NameTypeDescription
cellobjectGrid cell coordinates

Returns: array

Example

lolo
1 (grid/neighbors {"x":1,"y":1})

grid/screen-to-iso

Screen point to isometric cell coordinates

lolo
1 (grid/screen-to-iso x y z)

Parameters

NameTypeDescription
xnumberScreen x coordinate
ynumberScreen y coordinate
znumberScale or depth

Returns: point

Example

lolo
1 (grid/screen-to-iso 640 360 1)

grid/to-world

Cell to world-space center point

lolo
1 (grid/to-world x y)

Parameters

NameTypeDescription
xnumberCell x coordinate
ynumberCell y coordinate

Returns: point

Example

lolo
1 (grid/to-world 10 15) // => 150

vec/

vec/add

Componentwise vector addition a+b

lolo
1 (vec/add a b)

Parameters

NameTypeDescription
avectorFirst vector
bvectorSecond vector

Returns: vector

Example

lolo
1 (vec/add [1 2 3] [4 5 6]) // => [5 7 9]

vec/angle

Heading atan2(y,x) (1 arg) or angle between two vectors (2 args), radians

lolo
1 (vec/angle v other)

Parameters

NameTypeDescription
vvectorVector or heading
othervectorOther vector (variadic)

Returns: number

Example

lolo
1 (vec/angle [1 1]) // => 0.785

vec/clamp-length

Clamp magnitude to max (preserves direction)

lolo
1 (vec/clamp-length v max_length)

Parameters

NameTypeDescription
vvectorVector to clamp
max_lengthnumberMaximum magnitude

Returns: vector

Example

lolo
1 (vec/clamp-length [10 10] 12) // => [8.485 8.485]

vec/cross

3D cross product → vector; 2D → scalar ax·by-ay·bx

lolo
1 (vec/cross a b)

Parameters

NameTypeDescription
avectorFirst vector
bvectorSecond vector

Returns: vector | number

Example

lolo
1 (vec/cross [1 0 0] [0 1 0]) // => [0 0 1]

vec/distance

Euclidean distance length(sub(a,b))

lolo
1 (vec/distance a b)

Parameters

NameTypeDescription
avectorFirst point
bvectorSecond point

Returns: number

Example

lolo
1 (vec/distance [0 0] [3 4]) // => 5

vec/distance-sq

Squared distance length-sq(sub(a,b))

lolo
1 (vec/distance-sq a b)

Parameters

NameTypeDescription
avectorFirst point
bvectorSecond point

Returns: number

Example

lolo
1 (vec/distance-sq [0 0] [3 4]) // => 25

vec/dot

Dot product ax·bx+ay·by(+az·bz)

lolo
1 (vec/dot a b)

Parameters

NameTypeDescription
avectorFirst vector
bvectorSecond vector

Returns: number

Example

lolo
1 (vec/dot [1 2 3] [4 5 6]) // => 32

vec/length

Vector magnitude sqrt(dot(a,a))

lolo
1 (vec/length v)

Parameters

NameTypeDescription
vvectorVector

Returns: number

Example

lolo
1 (vec/length [3 4]) // => 5

vec/length-sq

Squared magnitude dot(a,a)

lolo
1 (vec/length-sq v)

Parameters

NameTypeDescription
vvectorVector

Returns: number

Example

lolo
1 (vec/length-sq [3 4]) // => 25

vec/lerp

Componentwise linear interpolation a+(b-a)*t

lolo
1 (vec/lerp a b t)

Parameters

NameTypeDescription
avectorStart vector
bvectorEnd vector
tnumberInterpolation factor

Returns: vector

Example

lolo
1 (vec/lerp [0 0] [10 10] 0.5) // => [5 5]

vec/normalize

Unit vector a/len; zero-length → zero vector (same dim)

lolo
1 (vec/normalize v)

Parameters

NameTypeDescription
vvectorVector to normalize

Returns: vector

Example

lolo
1 (vec/normalize [3 4]) // => [0.6 0.8]

vec/rotate

2D rotate by rad (z preserved): x'=x·cos-y·sin, y'=x·sin+y·cos

lolo
1 (vec/rotate v rad)

Parameters

NameTypeDescription
vvectorVector to rotate
radnumberRotation in radians

Returns: vector

Example

lolo
1 (vec/rotate [1 0] 1.57) // => [0 1]

vec/scale

Componentwise scalar multiply a*k

lolo
1 (vec/scale v k)

Parameters

NameTypeDescription
vvectorVector to scale
knumberScale factor

Returns: vector

Example

lolo
1 (vec/scale [1 2 3] 2) // => [2 4 6]

vec/sub

Componentwise vector subtraction a-b

lolo
1 (vec/sub a b)

Parameters

NameTypeDescription
avectorFirst vector
bvectorSecond vector

Returns: vector

Example

lolo
1 (vec/sub [5 7 9] [1 2 3]) // => [4 5 6]
Orb

The language where the rule is the program.

© 2026 Almadar. Ljubljana, Slovenia.