What is @types/mapbox__point-geometry?
@types/mapbox__point-geometry provides TypeScript type definitions for the mapbox/point-geometry library, which is a lightweight library for working with 2D points and performing geometric operations on them.
What are @types/mapbox__point-geometry's main functionalities?
Creating a Point
This feature allows you to create a new point with x and y coordinates.
const point = new Point(10, 20);
Adding Points
This feature allows you to add two points together, resulting in a new point.
const point1 = new Point(10, 20);
const point2 = new Point(5, 5);
const result = point1.add(point2);
Subtracting Points
This feature allows you to subtract one point from another, resulting in a new point.
const point1 = new Point(10, 20);
const point2 = new Point(5, 5);
const result = point1.sub(point2);
Scaling a Point
This feature allows you to scale a point by a given factor.
const point = new Point(10, 20);
const scaledPoint = point.mult(2);
Calculating Distance Between Points
This feature allows you to calculate the Euclidean distance between two points.
const point1 = new Point(10, 20);
const point2 = new Point(5, 5);
const distance = point1.dist(point2);
Other packages similar to @types/mapbox__point-geometry
point-geometry
The point-geometry package is the original JavaScript library for working with 2D points, which @types/mapbox__point-geometry provides type definitions for. It offers similar functionalities such as creating points, adding, subtracting, and scaling points, and calculating distances.
vector2d
The vector2d package provides a more comprehensive set of operations for 2D vectors, including geometric transformations, dot products, and cross products. It is more feature-rich compared to @types/mapbox__point-geometry but serves a similar purpose.
gl-vec2
The gl-vec2 package is part of the stack.gl collection and provides a set of functions for 2D vector operations. It is optimized for WebGL applications and offers a broader range of vector operations compared to @types/mapbox__point-geometry.
Installation
npm install --save @types/mapbox__point-geometry
Summary
This package contains type definitions for @mapbox/point-geometry (https://github.com/mapbox/point-geometry).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__point-geometry.
declare class Point {
x: number;
y: number;
constructor(x: number, y: number);
clone(): Point;
add(p: Point): Point;
_add(p: Point): Point;
sub(p: Point): Point;
_sub(p: Point): Point;
multiByPoint(p: Point): Point;
divByPoint(p: Point): Point;
mult(k: number): Point;
_mult(k: number): Point;
div(k: number): Point;
_div(k: number): Point;
rotate(k: number): Point;
_rotate(k: number): Point;
rotateAround(k: number, p: Point): Point;
_rotateAround(k: number, p: Point): Point;
matMult(m: number[]): Point;
_matMult(m: number[]): Point;
unit(): Point;
_unit(): Point;
perp(): Point;
_perp(): Point;
round(): Point;
_round(): Point;
mag(): number;
equals(other: Point): boolean;
dist(p: Point): number;
distSqr(p: Point): number;
angle(): number;
angleTo(b: Point): number;
angleWith(b: Point): number;
angleWithSep(x: number, y: number): number;
static convert<T extends unknown>(a: T): T extends number[] ? Point : T extends Point ? Point : T;
}
export = Point;
Additional Details
- Last updated: Tue, 07 Nov 2023 09:09:39 GMT
- Dependencies: none
Credits
These definitions were written by Mathieu Maes, and Harel Mazor.