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

regional

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regional

Given two points and a range of regions, determines which region the second point is in with relation to the first

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Regional

This library lets you split up a circle into regions and figure out what region a point is in with relation to a center point.

Here's an example:

import { determineRegion, getRegions } from 'regional'

// This breaks our 'circle' into four regions, like this:
//       │ 0/360 degrees
// ┌─────┼─────┐ 
// │  0  │  3  │  
// ├─────○─────│ 
// │  1  │  2  │ 
// └─────┴─────┘ 
const regions = getRegions(4);

const region = determineRegion(
  [0, 0],
  [-2, -2], // a point that is 45 degrees clockwise from the start
  regions
);
const i = regions.findIndex(r => r === region);
// i === 0

One thing to be careful of is where the starting angle is — the 0 degree mark is at the top vertical, not the right horizontal like is often seen. Also, x values increase from left to right, while y values increase from top to bottom

Methods

  • determineRegions(p1: [number, number], p2: [number, number], regions: Array<region>): region Returns the region object from the regions array that contains p2
  • getRegions(numberOfSides: number): Array<region> Returns an array of regions that is essentially a circle split into as many regions as the number provided

Keywords

FAQs

Package last updated on 17 Feb 2018

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