
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
constructs a binary space partitioning tree.
A BSP tree is a binary tree used to sort and search for polytopes in n-dimensional space.
For example, given a square somewhere in the XY plane, we select the first split, and thus the root of the BSP tree, to cut the square in half in the X direction. At each slice, we will choose a line of the opposite orientation from the last one, so the second slice will divide each of the new pieces in the Y direction.
The result is shown in the following figure along with the BSP tree which describes it:
+-----------+ +-----+-----+ +-----+-----+
| | | | | | | |
| | | | | | d | |
| | | | | | | |
| a | -> | b X c | -> +--Y--+ c | -> ...
| | | | | | | |
| | | | | | e | |
| | | | | | | |
+-----------+ +-----+-----+ +-----+-----+
a X X ...
-/ \+ -/ \+
/ \ / \
b c Y c
-/ \+
/ \
d e
to build such a tree that recursively divides its first half:
var bsp = require('bsp-tree');
var node = bsp(8),
vertical = true;
while (node.data.shape[0] > 1) {
vertical = !(node.split(vertical).dir);
node = node.leafs[0];
}
Returns a data structure tree that represents the root of a BSP tree of finite size.
Following methods are both applicable to a tree and its leafs.
Divides a tree (or a leaf) into leafs. Each leaf represents a convex region which is partitioned in two convex sub-regions at each side of a cut hyperplane. The root leaf contains the complete space.
Merges the split parts.
Flips the orientation.
Returns an array representation of a tree that you can use to create a copy.
var tree = bsp(4);
tree.split().leafs[0].split(true);
var copy = bsp(4, tree.serialize());
Following methods are only applicable to root node.
Given an offset of a leaf (that can be accessed through leaf.data.offset) these return the nearest plane's offset in x or y direction.
Nodes of a subdivision can be accessed through leafs array. If not divided this property is null by default.
Underlying ndarray instance which is shared among all split parts.
A boolean that indicates the split direction.
mit
FAQs
constructs a binary space partitioning tree
The npm package bsp-tree receives a total of 0 weekly downloads. As such, bsp-tree popularity was classified as not popular.
We found that bsp-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.