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 🙏

© 2026 – Pkg Stats / Ryan Hefner

intersecti0n

v1.0.0

Published

Intersection Библиотека определения пересечения геометрии фигуры и набора фигур

Downloads

2

Readme

Геометрическая Библиотека для Определения Пересечений

Описание

Эта библиотека предоставляет API для эффективного определения пересечений и положения объектов в двумерном пространстве. Библиотека использует R-дерево для быстрого поиска и управления геометрическими объектами, такими как прямоугольники и треугольники. Основные возможности включают:

  • Проверка пересечений между объектами
  • Нахождение объектов выше или ниже заданного объекта
  • Поиск объектов внутри определенной области

Библиотека предназначена для работы с различными геометрическими фигурами и может обрабатывать большие объемы данных в реальном времени.

Примеры использования

Инициализируем R-дерево с картой высот 100x100. Передаем начальное количество записей

const rtree = new RTree([100, 100]) 

Создаем геометрические объекты

const rect1 = new Rectangle(new MBR(0, 0, 10, 10))
const rect2 = new Rectangle(new MBR(15, 15, 25, 25))
const rect3 = new Rectangle(new MBR(5, 5, 15, 15))
const triangle1 = new Triangle([{ x: 1, y: 1 }, { x: 5, y: 1 }, { x: 3, y: 4 }])
const triangle2 = new Triangle([{ x: 3, y: 4 }, { x: 7, y: 4 }, { x: 5, y: 6 }])
const triangle3 = new Triangle([{ x: 20, y: 20 }, { x: 22, y: 22 }, { x: 21, y: 25 }])
const triangle4 = new Triangle([{ x: 0, y: 5 }, { x: 0, y: 10 }, { x: 4, y: 7 }])

Вставляем объекты в R-дерево

rtree.insert(rect1, 1)
rtree.insert(rect2, 2)
rtree.insert(triangle1, 3)
rtree.insert(triangle2, 4)
rtree.insert(triangle3, 5)
rtree.insert(rect3, 6)
rtree.insert(triangle4, 7)

Пример 1: Использование функции hasAnyIntersection

const queryMBR1 = new MBR(0, 0, 5, 5)
const queryMBR2 = new MBR(5, 5, 10, 10)
const queryMBR3 = new MBR(75, 75, 85, 85)

Проверяем, пересекается ли какой-либо объект в R-дереве с queryMBR1

const hasIntersection = hasAnyIntersection(queryMBR1, rtree)
console.log(`Есть ли пересечение с MBR1? ${hasIntersection}`)

Пример 2: Использование функции findIntersectingObjects

const intersectingIds = findIntersectingObjects(queryMBR1, rtree)
console.log(`Идентификаторы пересекающихся объектов MBR1: ${intersectingIds}`)
const intersectingIds2 = findIntersectingObjects(queryMBR2, rtree)
console.log(`Идентификаторы пересекающихся объектов MBR2: ${intersectingIds2}`)

Пример 3: Использование функции findObjectsAbove

const objectsAbove = findObjectsAbove(rect1, rtree) 
console.log(`Идентификаторы объектов выше прямоугольника 1: ${objectsAbove}`)

Пример 4: Использование функции findObjectsBelow

const objectsBelow = findObjectsBelow(rect2, rtree) 
console.log(`Идентификаторы объектов ниже прямоугольника 2: ${objectsBelow}`)

Пример 5 Проверяем пересечение двух треугольников

const doTrianglesIntersectResult = doTrianglesIntersect(triangle1, triangle2)
console.log(`triangle1 и triangle2 пересекаются: ${doTrianglesIntersectResult}`)