warpvas
Version:
This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.
26 lines (25 loc) • 775 B
TypeScript
/**
* Calculate intersection point of two line segments
*
* @param p1 - Line 1 start point {x: number, y: number}
* @param p2 - Line 1 end point
* @param p3 - Line 2 start point
* @param p4 - Line 2 end point
*
* @returns Intersection coordinates or null for parallel lines
*
* @example
* ```typescript
* // Intersecting lines
* calcIntersection({x:0,y:0}, {x:2,y:2}, {x:0,y:2}, {x:2,y:0}); // {x:1,y:1}
*
* // Parallel lines
* calcIntersection({x:0,y:0}, {x:1,y:1}, {x:0,y:1}, {x:1,y:2}); // null
* ```
*
* @remarks
* - Handles vertical/horizontal edge cases
* - Uses 1e4 scaling factor for floating-point precision
* - 0.1**12 parallel threshold
*/
export declare const calcIntersection: (p1: Coord, p2: Coord, p3: Coord, p4: Coord) => Coord | null;