Gamalto

Fork me on GitHub

Object Vector2 Overview

Gamalto. Vector2

new Gamalto.Vector2(x, y)

Creates a a vector with two components.

Parameters
Name Type Description
x number

X component of the vector.

y number

Y component of the vector.

Implements
Extends

Members

tag :object

inherited

Utility property to exchange data between objects.

Inherited From

Methods

add(vec) Gamalto.Vector2

Adds a vector to the current vector.

Parameters
Name Type Description
vec Gamalto.Vector2

Vector to add.

Returns
  • Current vector.

addNum(num) Gamalto.Vector2

Adds a scalar value to the current vector.

Parameters
Name Type Description
num number

Scalar value.

Returns
  • Current vector.

clone() Gamalto.Vector2

override

Creates a clone of the current object.

Overrides
Returns
  • Copy of the object.

div(vec) Gamalto.Vector2

Divides the current vector by a vector.

Parameters
Name Type Description
vec Gamalto.Vector2

Divisor vector.

Returns
  • Current vector.

divNum(num) Gamalto.Vector2

Divides the current vector by a scalar value.

Parameters
Name Type Description
num number

Scalar divisor.

Returns
  • Current vector.

equals(that) boolean

Determines if a vector is equal to the current vector.

Parameters
Name Type Description
that Gamalto.Vector2

Object to test.

Returns
  • True if the two vectors are equal.

getDistance(from) number

Calculates the distance from the specified vector.

Parameters
Name Type Description
from Gamalto.Vector2

Source vector.

Returns
  • Distance between the two vectors.

getLength() number

Gets the length of the vector.

Returns
  • number

isZero() boolean

Determines if a vector is a zero vector.

Returns
  • boolean

mul(vec) Gamalto.Vector2

Multiplies a vector by the current vector.

Parameters
Name Type Description
vec Gamalto.Vector2

Vector to multiply.

Returns
  • Current vector.

mulNum(num) Gamalto.Vector2

Multiplies the current vector by a scalar value.

Parameters
Name Type Description
num number

Scalar factor.

Returns
  • Current vector.

normalize() Gamalto.Vector2

Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector.

Returns
  • Current vector.

sub(vec) Gamalto.Vector2

Substracts a vector from the current vector.

Parameters
Name Type Description
vec Gamalto.Vector2

Vector to substract.

Returns
  • Current vector.

subNum(num) Gamalto.Vector2

Substracts a scalar value from the current vector.

Parameters
Name Type Description
num number

Vector to substract.

Returns
  • Current vector.

toString() string

inherited abstract

Converts the object into a string.

Inherited From
Returns
  • string

add(p1, p2) Gamalto.Vector2

static

Adds two vectors.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Source vector.

Returns
  • Resulting vector.

addNum(pt, num) Gamalto.Vector2

static

Adds a scalar value to a vector.

Parameters
Name Type Description
pt Gamalto.IPoint

Source vector.

num number

Scalar value.

Returns
  • Resulting vector.

catmullRom(p1, p2, p3, p4, amount) Gamalto.Vector2

static

Performs a Catmull-Rom interpolation.

Parameters
Name Type Description
p1 Gamalto.IPoint

First position in the interpolation.

p2 Gamalto.IPoint

Second position in the interpolation.

p3 Gamalto.IPoint

Third position in the interpolation.

p4 Gamalto.IPoint

Fourth position in the interpolation.

amount number

Weighting factor.

See
Returns
  • Result of the interpolation.

div(p1, p2) Gamalto.Vector2

static

Divides two vectors.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Divisor vector.

Returns
  • Resulting vector.

divNum(pt, num) Gamalto.Vector2

static

Divides a vector by a scalar value.

Parameters
Name Type Description
pt Gamalto.IPoint

Source vector.

num number

Scalar divisor.

Returns
  • Resulting vector.

dot(p1, p2) number

static

Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse angle between them.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Source vector.

Returns
  • Dot product of the two vectors.

equal(p1, p2) boolean

static

Determines if two vectors are equal.

Parameters
Name Type Description
p1 Gamalto.IPoint

Vector to test.

p2 Gamalto.IPoint

Vector to test.

Returns
  • True if the two vectors are equal.

getDistance(from, to) number

static

Calculates the distance between two vectors.

Parameters
Name Type Description
from Gamalto.IPoint

Source vector.

to Gamalto.IPoint

Source vector.

Returns
  • Distance between the two vectors.

hermite(p1, t1, p2, t2, amount) Gamalto.Vector2

static

Performs a Hermite spline interpolation.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source position vector.

t1 Gamalto.IPoint

Source tangent vector.

p2 Gamalto.IPoint

Source position vector.

t2 Gamalto.IPoint

Source tangent vector.

amount number

Weighting factor.

See
Returns
  • Result of the interpolation.

lerp(p1, p2, amount) Gamalto.Vector2

static

Performs a linear interpolation between two vectors.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Source vector.

amount number

Value between 0 and 1 indicating the weight of the second vector.

Returns
  • Linear interpolation of the two vectors.

mul(p1, p2) Gamalto.Vector2

static

Multiplies two vectors.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Source vector.

Returns
  • Resulting vector.

mulNum(pt, num) Gamalto.Vector2

static

Multiplies a vector by a scalar value.

Parameters
Name Type Description
pt Gamalto.IPoint

Source vector.

num number

Scalar factor.

Returns
  • Resulting vector.

sub(p1, p2) Gamalto.Vector2

static

Substracts two vectors.

Parameters
Name Type Description
p1 Gamalto.IPoint

Source vector.

p2 Gamalto.IPoint

Source vector.

Returns
  • Resulting vector.

subNum(pt, num) Gamalto.Vector2

static

Substracts a scalar value from a vector.

Parameters
Name Type Description
pt Gamalto.IPoint

Source vector.

num number

Scalar value.

Returns
  • Resulting vector.

Documentation generated by JSDoc 3.3.2 on Sun Sep 13 2015 20:13:31 GMT+0200 (CEST)