All files / utils angle.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14                      7x 6x  
import { Point } from '../types';
import { radiansToDegrees } from './radians-to-degrees';
import { zeroPoint } from './inc';
 
/*
  Angle between points
 
  @param [object]: X and Y coordinates of from point
  @param [object]: X and Y coordinates of to point
  @return [radian]: Angle between the two points in radians
*/
export const angle = (a: Point, b: Point = zeroPoint) =>
  radiansToDegrees(Math.atan2(b.y - a.y, b.x - a.x));