updated 2026-11-26·4 min read
Topological Set Verification
Archived design specification for Cattell CFIT Scale 3 Subtest 4 planar boolean conditions, Jordan curve winding-number ray casting, and anchor-envelope AIG.
Archived / Unshipped Spec: This page documents the planned geometric verifier for Cattell’s Culture Fair Intelligence Test (CFIT Scale 3, Subtest 4). No CFIT Scale 3 module or interactive Venn sandbox is wired into the live Flynn app (
modulescurrently shipsist-battery,ist-battery-unpad-1973, andutbk-snbt).
I originally planned Cattell’s CFIT Scale 3 alongside IST and UTBK, got as far as writing the geometric verifier spec, and then shelved it so I would actually finish the active batteries instead of leaving half-baked modules everywhere.
My first validator prototype also broke immediately. Each CFIT Subtest 4 item shows overlapping closed curves (circles, squares, triangles) with control dots and asks which of 5 candidate figures lets you place dots in the exact same inside-and-outside combination. To check clicks fast, I rasterized each shape in a unique solid color onto an offscreen <canvas> and called ctx.getImageData(x, y, 1, 1). Retina scaling and subpixel antialiasing blended border RGB values near edges, browsers smoothed paths slightly differently across OSes, and getImageData() forced synchronous GPU-to-CPU readbacks that tanked frame rates on phones.
Winding-Number Ray Casting
The replacement spec drops pixel sampling and checks polygon vertices directly using winding-number ray casting: cast a horizontal ray to the right from click point and count net upward vs. downward edge crossings.
export interface TopologicalCondition {
includedShapes: ShapeId[]
excludedShapes: ShapeId[]
}
When a horizontal ray along hits a polygon corner directly, a naive crossing test double-counts the vertex and flips the result from inside (1) to outside (2 or 0). Enforcing half-open vertical bounds prevents that:
- Upward edges qualify only if and sits strictly left of the edge.
- Downward edges qualify only if and sits strictly right of the edge.
- Strictly horizontal edges () satisfy neither inequality and are skipped automatically.
Math & Reference Sketch: Jordan Curves & computeWindingNumber
Let a stimulus consist of simple closed Jordan curves in . For any point , its membership signature is if and otherwise. A candidate figure matches iff:
For a closed curve and , the winding number is:
By the Jordan curve theorem, .
export function computeWindingNumber(
point: [number, number],
vertices: [number, number][],
epsilon: number = 1e-6
): number {
const [px, py] = point
let wn = 0
for (let i = 0; i < vertices.length - 1; i++) {
const [x1, y1] = vertices[i]
const [x2, y2] = vertices[i + 1]
if (y1 <= py) {
if (y2 > py) {
const cross = (x2 - x1) * (py - y1) - (px - x1) * (y2 - y1)
if (cross > epsilon) wn++
}
} else {
if (y2 <= py) {
const cross = (x2 - x1) * (py - y1) - (px - x1) * (y2 - y1)
if (cross < -epsilon) wn--
}
}
}
return wn
}Constrained Anchor Envelopes in AIG
Randomizing shape coordinates inside a bounding box produces impossible layouts over 30% of the time: for example, requiring a dot inside Circle and Square but outside Triangle when a giant Triangle covers both. Sampling shapes from constrained anchor envelopes guarantees a non-empty valid region before rendering, while rejecting points placed within of an outline stroke as ambiguous.
For the live planar geometry verification currently shipped on 2D figure dissections, see Amthauer IST-70.