All files line-length.ts

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

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 15 16 17                          1x 273755x 273755x  
import { type LineSegment } from './@types/geometry.ts';
 
/**
 * Calculates the length of a line segment.
 * @param line - The line segment for which to calculate the length.
 * @returns The length of the line segment.
 * @example
 * ```typescript
 * lineLength({ x0: 0, y0: 0, x1: 3, y1: 4 }); // 5
 * ```
 * @group Geometry
 * @category Line Segment
 */
export function lineLength(line: LineSegment): number {
  return Math.hypot(line.x1 - line.x0, line.y1 - line.y0);
}