warpvas
Version:
This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.
23 lines (22 loc) • 632 B
TypeScript
/**
* Calculate foot of perpendicular from point to line
*
* @param p1 - Line start point {x: number, y: number}
* @param p2 - Line end point coordinates
* @param p0 - Target point coordinates
*
* @returns Foot coordinates on the line
*
* @example
* ```typescript
* // Vertical line example
* const foot = calcPerpendicularIntersection(
* {x:0,y:10}, {x:20,y:10}, {x:5,y:15}
* ); // {x:5, y:10}
* ```
*
* @remarks
* - Input points must define a valid line
* - Works for infinite lines (not limited to segments)
*/
export declare const calcPerpendicularIntersection: (p1: Coord, p2: Coord, p0: Coord) => Coord;