# Class VENISON.UTILITIES.Vector2

A 2D Vector utility class.
Defined in: venison_engine.js.

Class Summary
Constructor Attributes Constructor Name and Description

Field Summary
Field Attributes Field Name and Description

The horizontal component of the vector.

The vertical component of the vector.
Method Summary
Method Attributes Method Name and Description

Add a vector to this one.

Copy the vector.

fnCross(iVector)
Calculate the cross product between this vector and another.

fnDot(iVector)
Calculate the dot product between this vector and another.

fnIncrementBy(iVector)
Increment the values of the vector.

Get the length of the vector.

Get the square length of the vector.

Multiply the vector with a scalar.

Negate the vector.

Normalize the vector.

fnRotate(iAngle)
Get a rotated version of this Vector2.

fnSubtract(iVector)
Subtract a vector from this one.
Class Detail
VENISON.UTILITIES.Vector2(iX, iY)
Parameters:
{Number} iX
The horizontal component of the vector.
{Number} iY
The vertical component of the vector.
Field Detail
{Number} x
The horizontal component of the vector.

{Number} y
The vertical component of the vector.
Method Detail
Add a vector to this one.
Parameters:
iVector
The vector to add to this one.
Returns:
A new Vector2.

fnCopy()
Copy the vector.
Returns:
A new Vector2 that is identical to the original one.

{Number} fnCross(iVector)
Calculate the cross product between this vector and another. NOTE: The cross product is not actually defined in 2D, but no one can stop us from pretending!
Parameters:
iVector
The vector to cross this vector with.
Returns:
{Number} This function returns the scalar value of the z-component of the vector derived from the cross product of this vector and iVector, when pretending they are 3D vectors with 0 as their z-values.

{Number} fnDot(iVector)
Calculate the dot product between this vector and another.
Parameters:
iVector
The vector to scalarly multiply this vector with.
Returns:
{Number} The dot product.

fnIncrementBy(iVector)
Increment the values of the vector.
Parameters:
iVector
The vector containing the values to increment this vector by.

{Number} fnLength()
Get the length of the vector.
Returns:
{Number} The length of this vector.

{Number} fnLengthSquared()
Get the square length of the vector.
Returns:
{Number} The square length of this vector.

fnMultiplyScalar(iScalar)
Multiply the vector with a scalar. Returns the result, leaving this Vector2 unaffected.
Parameters:
{Number} iScalar
The scalar value to multiply this vector with.
Returns:
The result of the scalar multiplication.

fnNegated()
Negate the vector.
Returns:
A new Vector2.

fnNormalize()
Normalize the vector.

fnRotate(iAngle)
Get a rotated version of this Vector2. This Vector2 is not affected.
Parameters:
{Number} iAngle