Class b2Vec2

A 2D column vector.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(x?: number, y?: number): b2Vec2

Creates a new vector 2.

Parameters

  • x?: number optional

    x value, default = 0.

  • y?: number optional

    y value, default = 0.

Returns

b2Vec2

Properties

public x: number

x value

public y: number

y value

Methods

public Abs()

Sets x and y to absolute values.

public Add(v: b2Vec2)

Adds the vector 2 to this vector 2. The result is stored in this vector 2.

Parameters

public Copy(): b2Vec2

Creates a copy of the vector 2.

Returns

b2Vec2

Copy of this vector 2.

public CrossFV(s: number)

Cross F V

Parameters

  • s: number

public CrossVF(s: number)

Cross V F

Parameters

  • s: number

public GetNegative(): b2Vec2

Gets the negative of this vector 2.

Returns

b2Vec2

Negative copy of this vector 2.

public IsValid(): boolean

True if the vector 2 is valid, otherwise false. A valid vector has finite values.

Returns

boolean

True if the vector 2 is valid, otherwise false.

public Length(): number

Calculates the length of the vector 2.

Returns

number

The length of the vector 2.

public LengthSquared(): number

Calculates the length squared of the vector2.

Returns

number

The length squared of the vector 2.

public static Make(x: number, y: number): b2Vec2

Creates a new vector 2 from the given values.

Parameters

  • x: number

    x value.

  • y: number

    y value.

Returns

b2Vec2

public MaxV(b: b2Vec2)

Calculates which vector has the maximum values and sets this vector to those values.

Parameters

  • b: b2Vec2

    Vector 2 to compare for maximum values.

public MinV(b: b2Vec2)

Calculates which vector has the minimum values and sets this vector to those values.

Parameters

  • b: b2Vec2

    Vector 2 to compare for minimum values.

public MulM(A: b2Mat22)

Matrix multiplication. Stores the result in this vector 2.

Parameters

public MulTM(A: b2Mat22)

Dot product multiplication. Stores the result in this vector 2.

Parameters

  • A: b2Mat22

    Matrix to multiply by.

public Multiply(a: number)

Vector multiplication. Stores the result in this vector 2.

Parameters

  • a: number

    Value to multiple the vector's values by.

public NegativeSelf()

Sets this vector 2 to its negative.

public Normalize(): number

Normalizes the vector 2 [0,1].

Returns

number

Length.

public Set(x?: number, y?: number)

Sets the vector 2.

Parameters

  • x?: number optional

    x value, default is 0.

  • y?: number optional

    y value, default is 0.

public SetV(v: b2Vec2)

Sets the vector 2 from a vector 2.

Parameters

  • v: b2Vec2

    Vector 2 to copy values from.

public SetZero()

Sets the vector 2 to zero values.

public Subtract(v: b2Vec2)

Subtracts the vector 2 from this vector 2. The result is stored in this vector 2.

Parameters

  • v: b2Vec2

    Vector 2 to subtract.