Skip to content

Cannon.Math.Vector2D

y-lohse edited this page Jan 12, 2013 · 2 revisions

Represents a vector in 2 dimensional space. Most methods return the same Vector2D object, making calls chainable.

List of properties

List of functions

Properties

x:Float

y:Float

Functions

__construct:Vector2D

Parameters

  • x:Float
  • y:Float

Description

Creates a new Vector2D

clone:Vector2D

Description

Returns a clone of the current vector.

add:Vector2D

Parameters

  • v2:Vector2D

Description

Adds another vector to this.

substract:Vector2D

Parameters

  • v2:Vector2D

Description

subtracts another vector to this.

multiply:Vector2D

Parameters

  • magnitude:Float

Description

Multiplies the current vector by a given value.

equals:Boolean

Parameters

  • v2:Vector2D

Description

Determines whether two vectors are equal

length:Float

Description

Computes the length of the current vector

normalize:Float

Description

Normalizes the current vector

rightNormal:Vector2D

Description

Returns the right normal of the current vector

leftNormal:Vector2D

Description

Returns the left normal of the current vector

dir:Vector2D

Description

Returns a new vector representing the direction of the current vector

proj:Boolean

Parameters

  • v2:Vector2D

Description

Projects this onto v2 and returns the resulting vector

projLength:Float

Parameters

  • v2:Vector2D

Description

Retuns the projection length of this and v2

dotProduct:Float

Parameters

  • v2:Vector2D

Description

Computes the dot product of this and v2

crossProduct:Float

Parameters

  • v2:Vector2D

Description

Computes the cross product of this and v2