@thi.ng/geom-poly-utils
Version:
2D polygon/polyline analysis & processing utilities
45 lines • 1.66 kB
TypeScript
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
/**
* Takes an array of polyline/polygon vertices and computes the tangent
* directions for each (point).
*
* @remarks
* Use `close=true` to indicate a polygon and cause the last tangent to be the
* direction from last vertex to the first. If `close=false`, the last point's
* tangent will be the same as the previous one.
*
* The optional `scale` arg can be used to scale the tangents (default: 1).
*
* @param pts -
* @param close -
* @param scale -
*/
export declare const tangents: (pts: ReadonlyVec[], close?: boolean, scale?: number) => Vec<number>[];
/**
* Extended version of {@link tangents}. Takes an array of polyline/polygon
* vertices and computes the smoothed tangent directions for each (point).
*
* @remarks
* By default, the tangent direction is proportionally influenced by the length
* ratio of a point's previous and current line segments: `currLen / (prevLen +
* currLen)`.
*
* If `proportional` is disabled, the tangents will be the simple mean of the
* direction of the prev/curr segments.
*
* The optional `scale` arg can be used to scale the tangents (default: 1).
*
* @param pts -
* @param close -
* @param proportional -
* @param scale -
*/
export declare const smoothTangents: (pts: ReadonlyVec[], close?: boolean, proportional?: boolean, scale?: number) => Vec<number>[];
/**
* Transforms an array of 2d tangent vectors into a new array with each tangent
* rotated 90 degrees counter-clockwise.
*
* @param tangents -
*/
export declare const bitangents2: (tangents: ReadonlyVec[]) => Vec<number>[];
//# sourceMappingURL=tangent.d.ts.map