Vector2.getDistance()
Compute and returns the distance between this vector and the vector given as parameter
Parameters
Name | Type | Description | |
---|---|---|---|
1 | v | Vector2 | |
2 | square | boolean |
Return value
number
The distance between the vectors
Usage
import {Vector2} from '@lcluber/type6js';
let vector1 = new Vector2(1,1);
let vector2 = new Vector2(2,2);
let squaredDistance = vector1.getDistance(vector2, true);
let distance = vector1.getDistance(vector2, false);
console.log(squaredDistance);
console.log(distance);