toosoon-utils
Version:
Utility functions & classes
76 lines (75 loc) • 2.36 kB
TypeScript
import type { Point2 } from '../../types';
import { Vector2 } from '../geometry';
import Curve from './Curve';
/**
* Utility class for manipulating lines
*
* @exports
* @class LineCurve
* @extends Curve<Vector2>
*/
export default class LineCurve extends Curve<Vector2> {
readonly type: string;
/**
* X-axis coordinate of the start point
*/
x1: number;
/**
* Y-axis coordinate of the start point
*/
y1: number;
/**
* X-axis coordinate of the end point
*/
x2: number;
/**
* Y-axis coordinate of the end point
*/
y2: number;
/**
* @param {number} x1 X-axis coordinate of the start point
* @param {number} y1 Y-axis coordinate of the start point
* @param {number} x2 X-axis coordinate of the end point
* @param {number} y2 Y-axis coordinate of the end point
*/
constructor(x1: number, y1: number, x2: number, y2: number);
/**
* Interpolate a point on this curve
*
* @param {number} t Normalized time value to interpolate
* @returns {Vector2} Interpolated coordinates on this curve
*/
getPoint(t: number): Vector2;
/**
* Interpolate a point on this line
*
* @param {number} u Normalized position value to interpolate
* @returns {Vector2} Interpolated coordinates on this line
*/
getPointAt(u: number): Vector2;
/**
* Compute an unit vector tangent for a given normalized time value
*
* @param {number} t Normalized time value
* @returns {Vector2} Tangent vector
*/
getTangent(t?: number): Vector2;
/**
* Compute an unit vector tangent for a given normalized position value
*
* @param {number} u Normalized position value
* @returns {Vector2} Tangent vector
*/
getTangentAt(u?: number): Vector2;
/**
* Interpolate a point on a line
*
* @param {number} t Normalized time value to interpolate
* @param {number} x1 X-axis coordinate of the start point
* @param {number} y1 Y-axis coordinate of the start point
* @param {number} x2 X-axis coordinate of the end point
* @param {number} y2 Y-axis coordinate of the end point
* @returns {Point2} Interpolated coordinates on the line
*/
static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): Point2;
}