Vectors and points for 2d graphics or geometry. All methods return new objects, so originals are never mutated.
import {V2, P2} from 'affine';
const v = V2(5, 5);
const p = P2(10, 10);
p.offset(v);
Initialize a new Vector
with x / y.
Check if this vector is equal to v
.
Add v
to this vector.
Subtract v
from this vector.
Scale this vector by s
.
Return the dot product of this vector and v
.
Return the magnitude of this vector.
Return a vector with the same direction as this one, and unit length. Returns the zero vector if this vector is zero as well.
Rotate this vector by s
radians.
Initialize a new Position
with x / y.
Check if this position is equal to p
.
Displace this position by the vector v
.
Return the displacement vector between this position and p
.
Return the distance between this position and p
.
MIT