Options
All
  • Public
  • Public/Protected
  • All
Menu

A 2d Vector class to that is mutable.

Due to the lack of AS3 operator overloading most methods exists in different names, all methods that ends with Self actually modifies the object itself (including obvious ones copy, copyXY and zero). For example v1 += v2; is written as v1.addSelf(v2);

The class in not commented properly yet - just subdivided into logical chunks.

author

playchilla.com

License: Use it as you wish and if you like it - link back!

Hierarchy

Index

Constructors

constructor

  • new Vec2(x?: number, y?: number): Vec2

Properties

_x

_x: number

_y

_y: number

Static EPSILON

EPSILON: number = 1e-7

Static EPSILONSQR

EPSILONSQR: number = Vec2.EPSILON * Vec2.EPSILON

Static ZERO

ZERO: Vec2Const = new Vec2Const()

Accessors

length

  • get length(): number

lengthSqr

  • get lengthSqr(): number

x

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

y

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

Methods

add

addSelf

addXY

  • addXY(x: number, y: number): Vec2

addXYSelf

  • addXYSelf(x: number, y: number): Vec2

clone

copy

copyXY

  • copyXY(x: number, y: number): Vec2

crossDet

crossDetXY

  • crossDetXY(x: number, y: number): number

distance

distanceSqr

distanceXY

  • distanceXY(x: number, y: number): number

distanceXYSqr

  • distanceXYSqr(x: number, y: number): number

div

divSelf

divXY

  • divXY(x: number, y: number): Vec2

divXYSelf

  • divXYSelf(x: number, y: number): Vec2

dot

dotXY

  • dotXY(x: number, y: number): number

equals

equalsXY

  • equalsXY(x: number, y: number): boolean

getDegrees

  • getDegrees(): number

getMax

getMin

getMinRadsBetween

getRads

  • getRads(): number

getRadsBetween

getRadsFullAngle

  • getRadsFullAngle(): number

isNear

isNearXY

  • isNearXY(x: number, y: number): boolean

isNormalized

  • isNormalized(): boolean

isValid

  • isValid(): boolean

isWithin

  • isWithin(vec2: Vec2Const, epsilon: number): boolean

isWithinXY

  • isWithinXY(x: number, y: number, epsilon: number): boolean

isZero

  • isZero(): boolean

lerp

lerpSelf

mirror

mul

mulSelf

mulXY

  • mulXY(x: number, y: number): Vec2

mulXYSelf

  • mulXYSelf(x: number, y: number): Vec2

negate

negateSelf

  • negateSelf(): Vec2

normalLeft

  • normalLeft(): Vec2

normalLeftSelf

  • normalLeftSelf(): Vec2

normalRight

  • normalRight(): Vec2

normalRightSelf

  • normalRightSelf(): Vec2

normalize

  • normalize(mag?: number): Vec2

normalizeSelf

  • normalizeSelf(): Vec2

reflect

rescale

  • rescale(newLength: number): Vec2

rescaleSelf

  • rescaleSelf(newLength: number): Vec2

rotate

  • rotate(rads: number): Vec2

rotateSelf

  • rotateSelf(rads: number): Vec2

rotateSpinor

rotateSpinorSelf

rotateSpinorXY

  • rotateSpinorXY(x: number, y: number): Vec2

scale

  • scale(s: number): Vec2

scaleSelf

  • scaleSelf(s: number): Vec2

slerp

spinorBetween

sub

subSelf

subXY

  • subXY(x: number, y: number): Vec2

subXYSelf

  • subXYSelf(x: number, y: number): Vec2

toString

  • toString(): string

zero

Static createRandomDir

  • createRandomDir(): Vec2

Static lawOfCosAngle

  • lawOfCosAngle(a: number, b: number, c: number): number

Static swap

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc