-
Notifications
You must be signed in to change notification settings - Fork 3
Home
description
By default size of stack is set to 10. But knowing JavaScript's dynamic nature it's size can be stretched to any limit. So, to prevent this an error will be thrown and instruction will be stopped. I will be using 'myStack' as an example variable.
-
Create a new Stack Object:
let myStack = new Stack();
-
Create a new Stack Object with size:
let myStack = new Stack(size_of_your_choice);
-
Push elements into Stack:
myStack.push(value);
This function returns the stack array -
Pop element from Stack:
myStack.pop();
This function returns the popped value -
Peek elements of Stack:
myStack.peek();
This function also returns the stack array
Library only provides static function. I will be using 'v' as an example variable name.
-
Create a new (0,0) vector:
let v = new Vector();
-
Create a new vector at (x,y):
let v = new Vector(x, y);
-
Addition of Vectors:
- add two vector:
Vector2D.add(vector_object, vector_object);
- addition of vector and a constant:
Vector2D.add(vector_object, constant);
- add two vector:
-
Scaling of Vectors:
- To a particular number:
Vector2D.setMag(constant, vector_object);
- With a vector:
Vector2D.mul(vector_object, vector_object);
- With a constant:
Vector2D.mul(vector_object, constant);
- To a particular number:
-
Subtraction of Vectors:
- Subtract two vector:
Vector2D.sub(vector_object, vector_object);
- Subtraction of vector and a constant:
Vector2D.sub(vector_object, constant);
- Subtract two vector:
-
Division of Vectors:
- Divide two vector:
Vector2D.div(vector_object, vector_object);
- Division of vector and a constant:
Vector2D.div(vector_object, constant);
- Divide two vector:
-
Dot Product of Vectors:
Vector2D.dot(vector_object, vector_object);
-
Magnitude of Vector:
Vector2D.magnitude(vector_object);
-
Normalization of Vectors:
Vector2D.normalize(vector_object);
-
Limit the size of a Vector:
Vector2D.limit(constant_limit, vector_object);
-
Distance between two Vectors:
Vector2D.distance(vector_object, vector_object);
-
Angle between two Vectors:
Vector2D.angleBetween(vector_object, vector_object);
+++++++++++++end++++++++++++++++