sussy-util
Version:
Util package made by me
42 lines (41 loc) • 1.95 kB
TypeScript
import Vector2d from './Vector2d';
export default class Point {
readonly x: number;
readonly y: number;
constructor(x: number, y: number);
/**
* This function takes a Point object as an argument and returns the distance between the two
* points.
* @param {Point} other - Point - The point to calculate the distance to.
* @returns The distance between two points.
*/
distanceTo(other: Point): number;
/**
* The slopeTo() function returns the slope between the invoking point (x0, y0) and the argument
* point (x1, y1) to be (y1 − y0) / (x1 − x0). Treat the slope of a horizontal line segment as
* positive zero; treat the slope of a vertical line segment as positive infinity; treat the slope
* of a degenerate line segment (between a point and itself) as negative infinity
* @param {Point} other - Point - The point to which the slope is being calculated.
* @returns The slope of the line between this point and the other point.
*/
slopeTo(other: Point): number;
/**
* The midpointTo() function returns the midpoint between the invoking point and the argument point.
* @param {Point} other - Point - The point to which the midpoint is being calculated.
* @returns The midpoint between this point and the other point.
*/
midpointTo(other: Point): Point;
/**
* Creates a Vector2d object from this point to the given point.
* @param other The point to create a vector towards.
* @returns A Vector2d object representing the vector from this point to the given point.
*/
vectorTo(other: Point): Vector2d;
/**
* Calculates the angle in degrees between two vectors formed by three points (this point, p1, and p2).
* @param p1 The second point.
* @param p2 The third point.
* @returns The angle in degrees between the two vectors.
*/
angleBetween(p1: Point, p2: Point): number;
}