Skip to main content

Transform

Transform

Class representing a Transform. A Transform holds all the spacial information about an object (ex. position, rotating, size, etc.).

For performance reasons the transform also stores a list of corners to be able to quickly apply intersection testing.


Constructor

public Transform

new Transform(pos, size, angle)

Constructs a new Transform object.

Parameters

  •  pos: Vector – The initial position of the transform.

  •  size: Vector – The initial size of the transform.

  •  angle: number – The initial angle of the transform.


Properties

No publicly accessible properties on Transform

private parent: Transform

Description needed

private pos: Vector

Description needed

private scale: Vector

Description needed

private angle: number

Description needed

private size: Vector

Description needed

private corners: Vector[]

Description needed

private localCorners: Vector[]

Description needed

private dirty: false | true

Description needed

private dirtySize: false | true

Description needed

private dirtyCorners: false | true

Description needed

private prevParentMatrix: Matrix2x3

Description needed

private matrix: Matrix2x3

Description needed

private inverse: Matrix2x3

Description needed

private radius: number

Description needed


Methods

private updateMatrix

updateMatrix() => void

Description needed

private updateSize

updateSize() => void

Description needed

private updateCorners

updateCorners() => void

Description needed

public calcRotationAbout

calcRotationAbout(a, c) => Vector<Vector, number>

Calculates the new position and angle after transforming this by 'a' radians about the axis 'c'.

Parameters

  •  a: number – The angle to rotate.

  •  c: Vector – The axis to rotate about.

Returns

  •   Vector<Vector, number> – The new position and angle to set to perform this rotation.

public setParent

setParent(t) => void

Description needed

Parameters

public setPos

setPos(p) => void

Description needed

Parameters

  •  p: VectorDescription needed

public setAngle

setAngle(a) => void

Description needed

Parameters

  •  a: numberDescription needed

public setScale

setScale(s) => void

Description needed

Parameters

  •  s: VectorDescription needed

public setSize

setSize(s) => void

Description needed

Parameters

  •  s: VectorDescription needed

public setWidth

setWidth(w) => void

Description needed

Parameters

  •  w: numberDescription needed

public setHeight

setHeight(h) => void

Description needed

Parameters

  •  h: numberDescription needed

public toLocalSpace

toLocalSpace(v) => Vector

Converts the given Vector, v, to local space relative to this transform.

Parameters

  •  v: Vector – The vector to transform, must be in world coordinates.

Returns

  •   Vector – The local space vector.

public toWorldSpace

toWorldSpace(v) => Vector

Converts the given Vector, v, to world space relative to this transform.

Parameters

  •  v: Vector – The vector to transform, must be in local coordinates.

Returns

  •   Vector – The world space vector.

public getParent

getParent() => Transform

Description needed

Returns

public getPos

getPos() => Vector

Description needed

Returns

  •   VectorDescription needed

public getAngle

getAngle() => number

Description needed

Returns

  •   numberDescription needed

public getScale

getScale() => Vector

Description needed

Returns

  •   VectorDescription needed

public getSize

getSize() => Vector

Description needed

Returns

  •   VectorDescription needed

public getRadius

getRadius() => number

Description needed

Returns

  •   numberDescription needed

public getMatrix

getMatrix() => Matrix2x3

Description needed

Returns

public getInverseMatrix

getInverseMatrix() => Matrix2x3

Description needed

Returns

public getTopLeft

getTopLeft() => Vector

Description needed

Returns

  •   VectorDescription needed

public getTopRight

getTopRight() => Vector

Description needed

Returns

  •   VectorDescription needed

public getBottomRight

getBottomRight() => Vector

Description needed

Returns

  •   VectorDescription needed

public getBottomLeft

getBottomLeft() => Vector

Description needed

Returns

  •   VectorDescription needed

public getCorners

getCorners() => Vector[]

Description needed

Returns

  •   Vector[]Description needed

public getLocalCorners

getLocalCorners() => Vector[]

Description needed

Returns

  •   Vector[]Description needed

public copy

copy() => Transform

Description needed

Returns


Static Methods

public FromCorners

FromCorners(p1, p2) => Transform

Description needed

Parameters

  •  p1: VectorDescription needed

  •  p2: VectorDescription needed

Returns