import type { MultiFn2O } from "@thi.ng/defmulti" ; import { defmulti } from "@thi.ng/defmulti/defmulti" ; import type { IShape } from "@thi.ng/geom-api" ; import type { ReadonlyVec , Vec } from "@thi.ng/vectors" ; import { madd } from "@thi.ng/vectors/madd" ; import { mixBilinear } from "@thi.ng/vectors/mix-bilinear" ; import type { Quad } from "./api/quad.js" ; import type { Rect } from "./api/rect.js" ; import { __dispatch } from "./internal/dispatch.js" ; /**
 * Projects given point `uv` (normalized coords) into the target space
 * defined by `shape` and writes result to `out` (or returns new
 * vector). See  mapPoint for reverse operation. Both functions
 * together can be used to warp points from one shape into another.
 *
 * Currently only implemented for these shape types:
 *
 * - AABB
 * - Quad
 * - Rect
 *
 *  param shape param uv param out export const unmapPoint = defmulti < any , ReadonlyVec , Vec | undefined , Vec > ( __dispatch , { aabb : "rect" , quad3 : "quad" , } , { quad : ( { points } , uv , out = [ ] ) => mixBilinear ( out , points [ 0 ] , points [ 1 ] , points [ 3 ] , points [ 2 ] , uv [ 0 ] , uv [ 1 ] ) , rect : ( $ , uvw , out = [ ] ) => madd ( out , $ . size , uvw , $ . pos ) , } ) ;