@amcharts/amcharts5
Version:
amCharts 5
238 lines • 8.7 kB
TypeScript
import type { IPoint } from "./IPoint";
import type { IBounds } from "./IBounds";
/**
* ============================================================================
* CONSTANTS
* ============================================================================
* @hidden
*/
export declare const PI: number;
export declare const HALFPI: number;
export declare const RADIANS: number;
export declare const DEGREES: number;
/**
* Rounds the numeric value to whole number or specific precision of set.
*
* @param value Value
* @param precision Precision (number of decimal points)
* @param floor In case value ends with 0.5 and precision is 0, we might need to floor the value instead of ceiling it.
* @return Rounded value
*/
export declare function round(value: number, precision?: number, floor?: boolean): number;
/**
* Ceils the numeric value to whole number or specific precision of set.
*
* @param value Value
* @param precision Precision (number of decimal points)
* @return Rounded value
*/
export declare function ceil(value: number, precision: number): number;
/**
* Returns the first control point for a cubic bezier spline segment
* interpolating through three consecutive points with the given tension.
*
* @ignore
* @param p0 Previous point
* @param p1 Current point
* @param p2 Next point
* @param tensionX Horizontal tension (0–1)
* @param tensionY Vertical tension (0–1)
* @return First control point
*/
export declare function getCubicControlPointA(p0: IPoint, p1: IPoint, p2: IPoint, tensionX: number, tensionY: number): IPoint;
/**
* Returns the second control point for a cubic bezier spline segment
* interpolating through three consecutive points with the given tension.
*
* @ignore
* @param p1 Current point
* @param p2 Next point
* @param p3 Point after next
* @param tensionX Horizontal tension (0–1)
* @param tensionY Vertical tension (0–1)
* @return Second control point
*/
export declare function getCubicControlPointB(p1: IPoint, p2: IPoint, p3: IPoint, tensionX: number, tensionY: number): IPoint;
/**
* Clamps a value to the given [min, max] range.
*
* @param value Value to clamp
* @param min Minimum
* @param max Maximum
* @return Clamped value
*/
export declare function fitToRange(value: number, min: number, max: number): number;
/**
* Returns sine of an angle specified in degrees.
*
* @param value Value
* @return Sine
*/
export declare function sin(angle: number): number;
/**
* Returns tan of an angle specified in degrees.
*
* @param value Value
* @return Sine
*/
export declare function tan(angle: number): number;
/**
* Returns cosine of an angle specified in degrees.
*
* @param value Value
* @return Cosine
*/
export declare function cos(angle: number): number;
/**
* Normalizes an angle to the 0–360 range.
*
* @param value Angle in degrees
* @return Normalized angle (0–360)
*/
export declare function normalizeAngle(value: number): number;
/**
* Returns the bounding box of a circular arc.
*
* @param cx Center X
* @param cy Center Y
* @param startAngle Start angle in degrees
* @param endAngle End angle in degrees
* @param radius Arc radius
* @return Bounding box
*/
export declare function getArcBounds(cx: number, cy: number, startAngle: number, endAngle: number, radius: number): IBounds;
/**
* Returns a point on a circle at the given angle.
*
* @param radius Circle radius
* @param arc Angle in degrees
* @return Point on the arc
*/
export declare function getArcPoint(radius: number, arc: number): {
x: number;
y: number;
};
/**
* Merges an array of bounds into a single bounding box that encompasses all of them.
*
* @param bounds Array of bounds to merge
* @return Combined bounding box
*/
export declare function mergeBounds(bounds: IBounds[]): IBounds;
/**
* Fits an angle into the given start/end range, snapping to the
* nearest boundary when the angle falls outside.
*
* @param value Angle in degrees
* @param startAngle Range start in degrees
* @param endAngle Range end in degrees
* @return Angle clamped to the range
*/
export declare function fitAngleToRange(value: number, startAngle: number, endAngle: number): number;
/**
* Returns `true` if a point is inside the given bounds (inclusive).
*
* @param point Point to test
* @param bounds Bounding box
* @return Whether the point is inside
*/
export declare function inBounds(point: IPoint, bounds: IBounds): boolean;
/**
* Returns the angle in degrees from `point1` to `point2`.
* If `point2` is omitted, uses double of `point1` coordinates.
*
* @param point1 Origin point
* @param point2 Target point (optional)
* @return Angle in degrees (0–360)
*/
export declare function getAngle(point1: IPoint, point2?: IPoint): number;
/**
* Returns a point on a quadratic bezier curve at the given position (0–1).
*
* @param pointA Start point
* @param pointB End point
* @param controlPoint Control point
* @param position Relative position (0 = start, 1 = end)
* @return Point on the curve
*/
export declare function getPointOnQuadraticCurve(pointA: IPoint, pointB: IPoint, controlPoint: IPoint, position: number): IPoint;
/**
* Returns a point on a cubic bezier curve at the given position (0–1).
*
* @param pointA Start point
* @param pointB End point
* @param controlPointA First control point (near start)
* @param controlPointB Second control point (near end)
* @param position Relative position (0 = start, 1 = end)
* @return Point on the curve
*/
export declare function getPointOnCubicCurve(pointA: IPoint, pointB: IPoint, controlPointA: IPoint, controlPointB: IPoint, position: number): IPoint;
/**
* Returns a point at a relative position along a straight line between two points.
*
* @param pointA Start point
* @param pointB End point
* @param position Relative position (0 = start, 1 = end)
* @return Point on the line
*/
export declare function getPointOnLine(pointA: IPoint, pointB: IPoint, position: number): IPoint;
/**
* Given a normalized location (0–1) along a multi-segment path and an array
* of cumulative segment lengths, returns which segment the location falls in
* and the local parameter t within that segment.
*
* @param location Relative position along the full path (0–1)
* @param cumulativeLengths Cumulative length at the end of each segment
* @return Segment index and local t (0–1)
*/
export declare function resolveLocationOnPath(location: number, cumulativeLengths: number[]): {
index: number;
t: number;
};
/**
* Returns the closest value from the array of values to the reference value.
*
* @param values Array of values
* @param value Reference value
* @return Closes value from the array
*/
export declare function closest(values: number[], referenceValue: number): number;
/**
* Returns true if bounds overlap
* @param bounds1 IBounds
* @param bounds2 IBounds
* @returns boolean
*/
export declare function boundsOverlap(bounds1: IBounds, bounds2: IBounds): boolean;
/**
* Generates points along a spiral path.
*
* @param cx Center X
* @param cy Center Y
* @param radius Outer radius
* @param radiusY Vertical radius (for elliptical spirals)
* @param innerRadius Inner radius where the spiral starts
* @param step Base step size between points
* @param radiusStep Radius increase per full revolution
* @param startAngle Start angle in degrees
* @param endAngle End angle in degrees
* @return Array of points along the spiral
*/
export declare function spiralPoints(cx: number, cy: number, radius: number, radiusY: number, innerRadius: number, step: number, radiusStep: number, startAngle: number, endAngle: number): IPoint[];
/**
* Returns `true` if two circles overlap or touch.
*
* @param circle1 First circle (x, y, radius)
* @param circle2 Second circle (x, y, radius)
* @return Whether the circles overlap
*/
export declare function circlesOverlap(circle1: {
x: number;
y: number;
radius: number;
}, circle2: {
x: number;
y: number;
radius: number;
}): boolean;
//# sourceMappingURL=Math.d.ts.map