npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graham-scanner

v1.1.3

Published

Implements Graham's Scan for finding the convex hull of a set of 2D vertices.

Downloads

38

Readme

Implements Graham's Scan for finding the convex hull of a set of 2D vertices.

Due to other packages no longer receiving new features—and buggy behaviour relating to vertices being collinear on the convex hull—this package has been created. This one should also be more computationally efficient, not using any [inverse] trigonometric functions.

Installation

npm install graham-scanner

Usage

import GrahamScan from "graham-scanner";

const scan = new GrahamScan();
scan.setVertices([
  { x: 11.1, y: -0.3 },
  { x: -11.111, y: -0.3 },
  { x: 2, y: 1.2 },
  { x: -0.0055, y: 4 },
]);
const hull = scan.generateHull();
console.log(hull);

Development Plans (the order is not particular)

  • [ ] Increase variety of input/output data structures for the list of vertices for GrahamScanner— to not force conversion on the user side to/from { x: number, y: number }[].
  • [x] Add options to change behaviour of the algorithm itself. Namely, whether or not to include collinear vertices in the hull, change the tolerance for floating point errors and potentially whether it walks counterclockwise or clockwise.
  • [ ] There is currently a check in the algorithm for every vertex if they have the same polar angle from P0 to skip iterating through all but the farthest one. This potentially introduces more overhead than its worth for computational effiecieny, and should be checked to be removed.
  • [ ] There is potential work to be done to increase numerical precision (for example from "Classroom examples of robustness problems in geometric computations" by Lutz Kettner et al).
  • [ ] There is potential to parallelize the algorithm using Web Workers. Starting references are the "All nearest smaller values" (ANSV) problem, which has a similar sequential implementation and a parallel algorithm ("Optimal doubly logarithmic parallel algorithms based on finding all nearest smaller values" by Berkman, Schieber & Vishkin, 1993) which uses a doubly logarithmic tree structure.

Contribution Guidelines

Please feel free to contribute however you'd like! Open

  • Issues for bug reports and feature requests
  • Pull Requests for addressing bugs or adding features as per open issues.