Vector2.setScalar()

Set the x and/or y values from the scalars given as parameters

Parameters

NameTypeDescription
1xnumber | nullValue of the X axis
2ynumber | null | undefinedValue of the Y axis

Return value

Vector2

The vector with its new values

Usage

import {Vector2} from '@lcluber/type6js';

// set from scalars
let vector = new Vector2(2,2);
console.log(vector); //(2,2)
vector.setScalar(1,1);
console.log(vector); //(1,1)

// set x axis only
let vector = new Vector2(3);
console.log(vector); //(3,0)
vector.setScalar(2);
console.log(vector); //(2,0)

// set y axis only
let vector = new Vector2(null, 3);
console.log(vector); //(0,3)
vector.setScalar(null,2);
console.log(vector); //(0,2)