gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
59 lines • 2.67 kB
TypeScript
import type { MValue, Properties, VectorPoint } from '../../../index.js';
/**
* An intersection of two segments
* u and t are where the intersection occurs
*/
export interface IntersectionOfSegments<D extends MValue = Properties> {
/** the intersection point */
point: VectorPoint<D>;
/** where along the first segment the intersection occurs */
u: number;
/** where along the second segment the intersection occurs */
t: number;
}
/**
* An intersection of two segments including displacement vectors
* u and t are where the intersection occurs
*/
export interface IntersectionOfSegmentsRobust<D extends MValue = Properties> {
/** the intersection point */
point: VectorPoint<D>;
/** where along the first segment the intersection occurs */
u: number;
/** where along the second segment the intersection occurs */
t: number;
/** displacement vector from the first segment */
uVec: VectorPoint<D>;
/** displacement vector from the second segment */
tVec: VectorPoint<D>;
/** Absolute angle of segment 'a' in radians [-PI, PI] */
uAngle: number;
/** Absolute angle of segment 'b' in radians [-PI, PI] */
tAngle: number;
}
/**
* Find the intersection of two segments
*
* NOTE: Segments that are only touching eachothers endpoints are considered intersections
* @param a - the first segment
* @param b - the second segment
* @returns A point if the segments intersect where the intersection occurs, otherwise undefined
*/
export declare function intersectionOfSegments<D extends MValue = Properties>(a: [VectorPoint<D>, VectorPoint<D>], b: [VectorPoint<D>, VectorPoint<D>]): IntersectionOfSegments<D> | undefined;
/**
* Find the intersection of two segments. A more robust approach that uses predicates to ensure no
* false positives/negatives
*
* NOTE:
* If the segments are touching at end points, they PASS in this function. However, the caviat is
* that if the segments are coming from the same ring, then the result will be undefined (not
* considered an intersection).
*
* NOTE: The resultant vectors are displacement vectors not normalized.
* @param a - the first segment
* @param b - the second segment
* @param sameRing - if both segments are from the same ring. By default it assumes they are
* @returns a point if the segments intersect where the intersection occurs, otherwise undefined
*/
export declare function intersectionOfSegmentsRobust<D extends MValue = Properties>(a: [VectorPoint<D>, VectorPoint<D>], b: [VectorPoint<D>, VectorPoint<D>], sameRing?: boolean): IntersectionOfSegmentsRobust<D> | undefined;
//# sourceMappingURL=intersection.d.ts.map