@ue-too/math / sameDirection
Function: sameDirection()
sameDirection(
a,b,precision):boolean
Defined in: index.ts:791
Checks if two vectors point in the same direction.
Parameters
a
First vector
b
Second vector
precision
number = 0.001
Tolerance for comparison (defaults to 0.001)
Returns
boolean
True if vectors have the same direction (after normalization)
Remarks
Normalizes both vectors to unit vectors and compares them. Magnitude does not matter, only direction.
Example
typescript
const a = { x: 1, y: 0 };
const b = { x: 10, y: 0 }; // Same direction, different magnitude
sameDirection(a, b); // true
const c = { x: 1, y: 1 };
sameDirection(a, c); // false (different direction)