UNPKG

toosoon-utils

Version:
80 lines (79 loc) 2.99 kB
import type { Point2 } from '../../types'; import { Vector2 } from '../geometry'; import Curve from './Curve'; /** * Utility class for manipulating ellipses * * @exports * @class EllipseCurve * @extends Curve */ export default class EllipseCurve extends Curve<Vector2> { readonly type: string; /** * X-axis coordinate of the center of the ellipse */ cx: number; /** * Y-axis coordinate of the center of the ellipse */ cy: number; /** * X-radius of the ellipse */ rx: number; /** * Y-radius of the ellipse */ ry: number; /** * Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis */ rotation: number; /** * Start angle of the arc (in radians) */ startAngle: number; /** * End angle of the arc (in radians) */ endAngle: number; /** * Flag indicating the direction of the arc */ counterclockwise: boolean; /** * @param {number} cx X-axis coordinate of the center of the ellipse * @param {number} cy Y-axis coordinate of the center of the ellipse * @param {number} rx X-radius of the ellipse * @param {number} ry Y-radius of the ellipse * @param {number} [rotation=0] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis * @param {number} [startAngle=0] Start angle of the arc (in radians) * @param {number} [endAngle=2*PI] End angle of the arc (in radians) * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc */ constructor(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean); /** * Interpolate a point on this curve * * @abstract * @param {number} t Normalized time value to interpolate * @returns {Vector2} Interpolated coordinates on this curve */ getPoint(t: number): Vector2; /** * Interpolate a point on an elliptical arc * * @param {number} t Normalized time value to interpolate * @param {number} cx X-axis coordinate of the center of the ellipse * @param {number} cy Y-axis coordinate of the center of the ellipse * @param {number} rx X-radius of the ellipse * @param {number} ry Y-radius of the ellipse * @param {number} [rotation=0] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis * @param {number} [startAngle=0] Start angle of the arc (in radians) * @param {number} [endAngle=2*PI] End angle of the arc (in radians) * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc * @returns {Point2} Interpolated coordinates on the arc */ static interpolate(t: number, cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): Point2; }