Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObservableVector2<T>

Type parameters

  • T = any

Hierarchy

  • ObservableVector2

Implements

Index

Constructors

constructor

  • Creates a new ObservableVector2.

    Type parameters

    • T = any

    Parameters

    • cb: () => any

      The callback to call whenever a value change.

        • (): any
        • Returns any

    • scope: T

      Owner of callback

    • x: number = 0

      Position of the vector on the X axis.

    • y: number = 0

      Position of the vector on the Y axis.

    • Optional fromObject: ObservablePoint<any>

    Returns ObservableVector2<T>

Properties

_x

_x: number

_y

_y: number

cb

cb: () => any

Type declaration

    • (): any
    • Returns any

scope

scope: T

Accessors

x

  • get x(): number
  • set x(value: number): void

xy

  • get xy(): XY
  • set xy(values: XY): void

y

  • get y(): number
  • set y(value: number): void

Methods

abs

add

clone

copyFrom

copyTo

  • copyTo<T>(p: T): T
  • Copies the x- and y-components from the source to the destination. The source and destination must be of the same type.

    Type parameters

    • T: IPointData

      The type of your source, can also be a ObservableVector2.

    Parameters

    • p: T

      The source point.

    Returns T

    • The resulting object.

deepClone

divide

equals

  • equals(other: IPointData, threshold?: number): boolean
  • Checks if two vectors are equal, using a threshold to avoid floating-point precision errors.

    Parameters

    • other: IPointData

      The other vector to compare with.

    • threshold: number = 0.00001

      The minimal difference required to say that the vectors are different, to avoid floating-point precision errors.

    Returns boolean

    • If vectors are equals.

greaterThan

length

  • length(): number

multiply

negate

normalize

reset

  • reset(): void

scale

set

squaredLength

  • squaredLength(): number

subtract

toJSON

  • toJSON(): { x: number; y: number }

toString

  • toString(): string

toVector

Static fromPoint

Generated using TypeDoc