BGE/ImpostorFit

Alias: BGE.ImpostorFit


Static Methods

fitScaleTranslate( fromX: Array.<float>, fromY: Array.<float>, toX: Array.<float>, toY: Array.<float>, ): FitResult

static

Fits x' = sx * x + tx and y' = sy * y + ty by least squares - what a single DrawScaledObject can draw. A mirrored or collapsed axis isn't usable.

Parameters

  • fromX (Array.<float>) — captured x of each point
  • fromY (Array.<float>) — captured y of each point
  • toX (Array.<float>) — current x of each point
  • toY (Array.<float>) — current y of each point

Returns

fitRotateScale( fromX: Array.<float>, fromY: Array.<float>, toX: Array.<float>, toY: Array.<float>, ): FitResult

static

Fits a rotation about the points' centre, then a scale along each rotated axis - what a single DrawTransformedObject can draw. The rotation comes from the best similarity fit, then each axis's scale by least squares, so it isn't the joint optimum but is close for the small rotations an impostor sees.

Parameters

  • fromX (Array.<float>)
  • fromY (Array.<float>)
  • toX (Array.<float>)
  • toY (Array.<float>)

Returns

fitAffine( fromX: Array.<float>, fromY: Array.<float>, toX: Array.<float>, toY: Array.<float>, ): FitResult

static

Fits a general affine map by least squares - what a corner pin of the captured bitmap draws, since drawPinnedCorners warps a parallelogram exactly.

Parameters

  • fromX (Array.<float>)
  • fromY (Array.<float>)
  • toX (Array.<float>)
  • toY (Array.<float>)

Returns

mapRotateScale( params: roAssociativeArray, x: float, y: float, ): BGE.Math.Vector

static

Where fitRotateScale()'s params take the point (x, y).

Parameters

  • params (roAssociativeArray) — a fitRotateScale() result's params
  • x (float)
  • y (float)

Returns

  • BGE.Math.Vector

fitPinnedCorners( fromX: Array.<float>, fromY: Array.<float>, toX: Array.<float>, toY: Array.<float>, width: float, height: float, ): FitResult

static

Fits where to pin the 4 corners of a width x height bitmap so the points land where they are now - what drawPinnedCorners draws with its top left to bottom right diagonal: two triangles, each an affine warp of its half of the bitmap. Least squares over the 4 corners at once, so the triangles always agree along the diagonal. from points are in the bitmap's own pixels. A corner no point constrains is pulled to where the best single affine map would put it.

Parameters

  • fromX (Array.<float>)
  • fromY (Array.<float>)
  • toX (Array.<float>)
  • toY (Array.<float>)
  • width (float) — the bitmap's width
  • height (float) — the bitmap's height

Returns

  • FitResult — params: cornersX/cornersY (top left, top right, bottom right, bottom left), width, height

mapPinnedCorners( params: roAssociativeArray, x: float, y: float, ): BGE.Math.Vector

static

Where fitPinnedCorners()'s params take the bitmap pixel (x, y).

Parameters

  • params (roAssociativeArray) — a fitPinnedCorners() result's params
  • x (float)
  • y (float)

Returns

  • BGE.Math.Vector

convexHullIndexes( xs: Array.<float>, ys: Array.<float>, ): Array.<integer>

static

The indexes of the points on their convex hull, in order around it.

Parameters

  • xs (Array.<float>)
  • ys (Array.<float>)

Returns

  • Array.<integer>

hullCandidates( xs: Array.<float>, ys: Array.<float>, ): Array.<integer>

static

The points that may be on the hull: those outside the octagon through the extreme points along x, y and both diagonals, which for a model's vertices is most of them gone before the sort.

Parameters

  • xs (Array.<float>)
  • ys (Array.<float>)

Returns

  • Array.<integer>

cross2d( xs: Array.<float>, ys: Array.<float>, a: integer, b: integer, c: integer, ): float

static

Parameters

  • xs (Array.<float>)
  • ys (Array.<float>)
  • a (integer)
  • b (integer)
  • c (integer)

Returns

  • float

pinWeights(u: float, v: float): Array.<float>

static

A bitmap point's weight on each pinned corner (top left, top right, bottom right, bottom left), from u = x / width and v = y / height.

Parameters

  • u (float)
  • v (float)

Returns

  • Array.<float>

solve4(matrix: roArray, rhs: Array.<float>): Array.<float>

static

Solves the 4x4 system m * x = rhs by Gaussian elimination, or invalid if it's singular. Neither argument is changed.

Parameters

  • matrix (roArray)
  • rhs (Array.<float>)

Returns

  • Array.<float>

fitAxis( fromValues: Array.<float>, toValues: Array.<float>, ): roAssociativeArray

static

Parameters

  • fromValues (Array.<float>)
  • toValues (Array.<float>)

Returns

  • roAssociativeArray

mean(values: Array.<float>): float

static

Parameters

  • values (Array.<float>)

Returns

  • float

unusable(): FitResult

static

Returns

Other

FitResult

static

How well one 2D mapping takes a set of captured canvas points to where they are now - see specs/2026-10-22-model-impostors-design.md. residual is the farthest any point lands from where it really is, in pixels; invalid params mean the fit isn't usable.

Properties

  • residual (float)
  • params (roAssociativeArray) — scale + translate: x' = scaleX * x + offsetX, y' = scaleY * y + offsetY