@plait/graph-viz
Version:
#### Dependence - `@plait/core`
56 lines (55 loc) • 2.26 kB
TypeScript
/**
* Modulate a value between two ranges.
* @param value
* @param rangeA from [low, high]
* @param rangeB to [low, high]
* @param clamp
*/
export declare function modulate(value: number, rangeA: number[], rangeB: number[], clamp?: boolean): number;
/**
* Rotate a point around a center.
* @param x The x-axis coordinate of the point.
* @param y The y-axis coordinate of the point.
* @param cx The x-axis coordinate of the point to rotate round.
* @param cy The y-axis coordinate of the point to rotate round.
* @param angle The distance (in radians) to rotate.
*/
export declare function rotatePoint(x: number, y: number, cx: number, cy: number, angle: number): number[];
/**
* Get the distance between two points.
* @param x0 The x-axis coordinate of the first point.
* @param y0 The y-axis coordinate of the first point.
* @param x1 The x-axis coordinate of the second point.
* @param y1 The y-axis coordinate of the second point.
*/
export declare function getDistance(x0: number, y0: number, x1: number, y1: number): number;
/**
* Get an angle (radians) between two points.
* @param x0 The x-axis coordinate of the first point.
* @param y0 The y-axis coordinate of the first point.
* @param x1 The x-axis coordinate of the second point.
* @param y1 The y-axis coordinate of the second point.
*/
export declare function getAngle(x0: number, y0: number, x1: number, y1: number): number;
/**
* Move a point in an angle by a distance.
* @param x0
* @param y0
* @param a angle (radians)
* @param d distance
*/
export declare function projectPoint(x0: number, y0: number, a: number, d: number): number[];
/**
* Get the sector of an angle (e.g. quadrant, octant)
* @param a The angle to check.
* @param s The number of sectors to check.
*/
export declare function getSector(a: number, s?: number): number;
/**
* Get a normal value representing how close two points are from being at a 45 degree angle.
* @param x0 The x-axis coordinate of the first point.
* @param y0 The y-axis coordinate of the first point.
* @param x1 The x-axis coordinate of the second point.
* @param y1 The y-axis coordinate of the second point.
*/
export declare function getAngliness(x0: number, y0: number, x1: number, y1: number): number;