New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

point2d

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

point2d

A point in 2d space

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

point2d

A point in 2d space

npm install point2d --save

Example

var Point = require('point2d');

var point1 = new Point(1, 2);
console.log(point1.x); // 1
console.log(point1.y); // 2

var point2 = new Point(); // (0, 0)

console.log(new Point().distance(new Point())); // 5

console.log(new Point().manhattanDistance(new Point())); // 7

console.log(new Point(-3, 4).abs()); // (3, 4)

console.log(new Point(1, 2).equals(new Point(1, 2))); // true

console.log(new Point(1, 2).add(new Point(2, 3))); // (3, 5)

console.log(new Point(1, 2).sub(new Point(1, 1))); // (0, 1)

Methods

Point.distance(point2d)

Returns the Euclidean distance between this point and another point

Point.manhattanDistance(point2d)

Returns the Manhattan distance between this point and another point

Point.abs()

Returns a new point with coordinates in absolute value

Point.equals(point2d)

Returns true if the x and y coordinate of this point equals the x and y coordinate of the other point

Point.add(point2d)

Returns a new point with the coordinates added together

Point.sub(point2d)

Returns a new point with the coordinates of this point subtracted by the other point

Keywords

point

FAQs

Package last updated on 31 Oct 2014

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