8 lines
261 B
TypeScript
8 lines
261 B
TypeScript
import type { Point } from './types';
|
|
|
|
export function scaleFromLine(a: Point, b: Point, lengthMm: number): number | null {
|
|
const lengthPx = Math.hypot(b.x - a.x, b.y - a.y);
|
|
if (!(lengthMm > 0) || lengthPx < 1) return null;
|
|
return lengthPx / lengthMm;
|
|
}
|