Readonly
xReadonly
xyReturns the x, y components of this. May be implemented as a getter method.
Readonly
yReadonly
zReturn this' angle in the XY plane (treats this as a Vec2).
This is equivalent to Math.atan2(vec.y, vec.x)
.
As such, observing that Math.atan2(-0, -1)
and Math.atan2(0, -1)
the resultant angle is in the range .
Example:
import { Vec2 } from '@js-draw/math'; console.log(Vec2.of(-1, -0).angle()); // atan2(-0, -1) console.log(Vec2.of(-1, 0).angle()); // atan2(0, -1)
Like normalized, except returns zero if this has zero magnitude.
A vector with three components, xyz. Can also be used to represent a two-component vector.
A
Vec3
is immutable.Example