Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mapbox/point-geometry

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/point-geometry

a point geometry with transforms

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7M
increased by6.19%
Maintainers
1
Weekly downloads
 
Created

What is @mapbox/point-geometry?

@mapbox/point-geometry is a lightweight library for handling 2D point geometry. It provides a simple API for creating and manipulating points, performing geometric operations, and calculating distances and angles between points.

What are @mapbox/point-geometry's main functionalities?

Creating Points

This feature allows you to create a new point with x and y coordinates. The code sample demonstrates how to create a point at coordinates (10, 20).

const Point = require('@mapbox/point-geometry');
const point = new Point(10, 20);
console.log(point);

Adding Points

This feature allows you to add two points together. The code sample demonstrates how to add point1 (10, 20) and point2 (5, 5) to get a new point (15, 25).

const Point = require('@mapbox/point-geometry');
const point1 = new Point(10, 20);
const point2 = new Point(5, 5);
const result = point1.add(point2);
console.log(result);

Subtracting Points

This feature allows you to subtract one point from another. The code sample demonstrates how to subtract point2 (5, 5) from point1 (10, 20) to get a new point (5, 15).

const Point = require('@mapbox/point-geometry');
const point1 = new Point(10, 20);
const point2 = new Point(5, 5);
const result = point1.sub(point2);
console.log(result);

Calculating Distance

This feature allows you to calculate the Euclidean distance between two points. The code sample demonstrates how to calculate the distance between point1 (10, 20) and point2 (13, 24).

const Point = require('@mapbox/point-geometry');
const point1 = new Point(10, 20);
const point2 = new Point(13, 24);
const distance = point1.dist(point2);
console.log(distance);

Rotating Points

This feature allows you to rotate a point around the origin by a given angle. The code sample demonstrates how to rotate a point (10, 20) by 45 degrees.

const Point = require('@mapbox/point-geometry');
const point = new Point(10, 20);
const angle = Math.PI / 4; // 45 degrees in radians
const rotatedPoint = point.rotate(angle);
console.log(rotatedPoint);

Other packages similar to @mapbox/point-geometry

Keywords

FAQs

Package last updated on 21 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc