JSVec2Array
An object for arrays of 2D coordinates.
Create a new Module.JSVec2Array API.
var vec_array = new Module.JSVec2Array();Function
clear()
Initializes the vector list.
var vectorList = new Module.JSVec2Array();
vectorList.clear();count() → number
Returns the number of vectors in the vector list.
- Return - number: The number of vectors in the list. 
 
var vectorList = new Module.JSVec2Array();
// ...
vectorList.count();get(index) → JSVector2D
Returns the vector object corresponding to the index.
index
number
The index of the vector to return.
- Return - A valid vector object (JSVector2D): Successfully returns the vector at the specified index. 
- An initialized object (JSVector2D): If the index exceeds the size of the vector list. 
 
var vectorList = new Module.JSVec2Array();
var vector = vectorList.get(2);pop() → JSVector2D
Returns the last vector in the vector list.
After returning, the last vector is deleted from the vector list.
- Return - A valid vector object (JSVector2D): Successfully returns the last vector. 
- An initialized object (JSVector2D): If the vector list is empty. 
 
var vectorList = new Module.JSVec2Array();
//...
var lastVector = vectorList.pop();push(element) → number
Adds a new vector (JSVector2D).
- Return - number: The number of vectors in the list after adding the new vector. 
 
var vectorList = new Module.JSVec2Array();
var newVector = new Module.JSVector2d(100.0, 150.0);
vectorList.push(newVector);pushXY(dX, dY) → number
Adds a new vector object using x, y values.
dX
number
The x property of the new vector.
dY
number
The y property of the new vector.
- Return - number: The number of vectors in the list after adding the new vector. 
 
var vectorList = new Module.JSVec2Array();
vectorList.pushXY(100.0, 120.0);set(index, vec)
Resets the value of the vector at the specified index.
index
number
The index of the vector to set.
var vectorList = new Module.JSVec2Array();
//...
var newVector = new Module.JSVector2D(130.22, 149.3);
vectorList.set(5, newVector);setXY(index, dX, dY)
Resets the value of the vector at the specified index using x, y values.
index
number
The index of the vector to set.
dX
number
The x value to set for the vector.
dY
number
The y value to set for the vector.
var vectorList = new Module.JSVec2Array();
//...
vectorList.setXY(5, 130.22, 149.3);shift()
Returns the first vector in the vector list and moves the order of the remaining vectors one position forward.
- Return - A valid vector object (JSVector2D): Successfully returns the first vector. 
- An initialized object (JSVector2D): If the vector list is empty. 
 
var vectorList = new Module.JSVec2Array();
//...
var lastVector = vectorList.shift();Last updated
