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

d3-octree

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-octree - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

build/d3-octree.js

@@ -1,2 +0,2 @@

// https://github.com/vasturiano/d3-octree Version 0.1.0. Copyright 2017 Vasco Asturiano.
// https://github.com/vasturiano/d3-octree Version 0.1.1. Copyright 2017 Vasco Asturiano.
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

@@ -1,2 +0,2 @@

// https://github.com/vasturiano/d3-octree Version 0.1.0. Copyright 2017 Vasco Asturiano.
// https://github.com/vasturiano/d3-octree Version 0.1.1. Copyright 2017 Vasco Asturiano.
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.d3=t.d3||{})}(this,function(t){"use strict";function i(t,i,e,n,s){if(isNaN(i)||isNaN(e)||isNaN(n))return t;var r,h,o,a,l,_,u,f,c,y,x,w,d=t._root,p={data:s},z=t._x0,N=t._y0,v=t._z0,g=t._x1,A=t._y1,b=t._z1;if(!d)return t._root=p,t;for(;d.length;)if((f=i>=(h=(z+g)/2))?z=h:g=h,(c=e>=(o=(N+A)/2))?N=o:A=o,(y=n>=(a=(v+b)/2))?v=a:b=a,r=d,!(d=d[x=y<<2|c<<1|f]))return r[x]=p,t;if(l=+t._x.call(null,d.data),_=+t._y.call(null,d.data),u=+t._z.call(null,d.data),i===l&&e===_&&n===u)return p.next=d,r?r[x]=p:t._root=p,t;do{r=r?r[x]=new Array(8):t._root=new Array(8),(f=i>=(h=(z+g)/2))?z=h:g=h,(c=e>=(o=(N+A)/2))?N=o:A=o,(y=n>=(a=(v+b)/2))?v=a:b=a}while((x=y<<2|c<<1|f)==(w=(u>=a)<<2|(_>=o)<<1|l>=h));return r[w]=d,r[x]=p,t}function e(t){var e,n,s,r,h,o=t.length,a=new Array(o),l=new Array(o),_=new Array(o),u=1/0,f=1/0,c=1/0,y=-(1/0),x=-(1/0),w=-(1/0);for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||isNaN(h=+this._z.call(null,e))||(a[n]=s,l[n]=r,_[n]=h,s<u&&(u=s),s>y&&(y=s),r<f&&(f=r),r>x&&(x=r),h<c&&(c=h),h>w&&(w=h));for(y<u&&(u=this._x0,y=this._x1),x<f&&(f=this._y0,x=this._y1),w<c&&(c=this._z0,w=this._z1),this.cover(u,f,c).cover(y,x,w),n=0;n<o;++n)i(this,a[n],l[n],_[n],t[n]);return this}function n(t){for(var i=0,e=t.length;i<e;++i)this.remove(t[i]);return this}function s(t){return t[0]}function r(t){return t[1]}function h(t){return t[2]}function o(t,i,e,n){var o=new a(null==i?s:i,null==e?r:e,null==n?h:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function a(t,i,e,n,s,r,h,o,a){this._x=t,this._y=i,this._z=e,this._x0=n,this._y0=s,this._z0=r,this._x1=h,this._y1=o,this._z1=a,this._root=void 0}function l(t){for(var i={data:t.data},e=i;t=t.next;)e=e.next={data:t.data};return i}var _=function(t){var e=+this._x.call(null,t),n=+this._y.call(null,t),s=+this._z.call(null,t);return i(this.cover(e,n,s),e,n,s,t)},u=function(t,i,e){if(isNaN(t=+t)||isNaN(i=+i)||isNaN(e=+e))return this;var n=this._x0,s=this._y0,r=this._z0,h=this._x1,o=this._y1,a=this._z1;if(isNaN(n))h=(n=Math.floor(t))+1,o=(s=Math.floor(i))+1,a=(r=Math.floor(e))+1;else{if(!(n>t||t>h||s>i||i>o||r>e||e>a))return this;var l,_,u=h-n,f=this._root;switch(_=(e<(r+a)/2)<<2|(i<(s+o)/2)<<1|t<(n+h)/2){case 0:do{l=new Array(8),l[_]=f,f=l}while(u*=2,h=n+u,o=s+u,a=r+u,t>h||i>o||e>a);break;case 1:do{l=new Array(8),l[_]=f,f=l}while(u*=2,n=h-u,o=s+u,a=r+u,n>t||i>o||e>a);break;case 2:do{l=new Array(8),l[_]=f,f=l}while(u*=2,h=n+u,s=o-u,a=r+u,t>h||s>i||e>a);break;case 3:do{l=new Array(8),l[_]=f,f=l}while(u*=2,n=h-u,s=o-u,a=r+u,n>t||s>i||e>a);break;case 4:do{l=new Array(8),l[_]=f,f=l}while(u*=2,h=n+u,o=s+u,r=a-u,t>h||i>o||r>e);break;case 5:do{l=new Array(8),l[_]=f,f=l}while(u*=2,n=h-u,o=s+u,r=a-u,n>t||i>o||r>e);break;case 6:do{l=new Array(8),l[_]=f,f=l}while(u*=2,h=n+u,s=o-u,r=a-u,t>h||s>i||r>e);break;case 7:do{l=new Array(8),l[_]=f,f=l}while(u*=2,n=h-u,s=o-u,r=a-u,n>t||s>i||r>e)}this._root&&this._root.length&&(this._root=f)}return this._x0=n,this._y0=s,this._z0=r,this._x1=h,this._y1=o,this._z1=a,this},f=function(){var t=[];return this.visit(function(i){if(!i.length)do{t.push(i.data)}while(i=i.next)}),t},c=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},y=function(t,i,e,n,s,r,h){this.node=t,this.x0=i,this.y0=e,this.z0=n,this.x1=s,this.y1=r,this.z1=h},x=function(t,i,e,n){var s,r,h,o,a,l,_,u,f,c=this._x0,x=this._y0,w=this._z0,d=this._x1,p=this._y1,z=this._z1,N=[],v=this._root;for(v&&N.push(new y(v,c,x,w,d,p,z)),null==n?n=1/0:(c=t-n,x=i-n,w=e-n,d=t+n,p=i+n,z=e+n,n*=n);u=N.pop();)if(!(!(v=u.node)||(r=u.x0)>d||(h=u.y0)>p||(o=u.z0)>z||(a=u.x1)<c||(l=u.y1)<x||(_=u.z1)<w))if(v.length){var g=(r+a)/2,A=(h+l)/2,b=(o+_)/2;N.push(new y(v[7],g,A,b,a,l,_),new y(v[6],r,A,b,g,l,_),new y(v[5],g,h,b,a,A,_),new y(v[4],r,h,b,g,A,_),new y(v[3],g,A,o,a,l,b),new y(v[2],r,A,o,g,l,b),new y(v[1],g,h,o,a,A,b),new y(v[0],r,h,o,g,A,b)),(f=(e>=b)<<2|(i>=A)<<1|t>=g)&&(u=N[N.length-1],N[N.length-1]=N[N.length-1-f],N[N.length-1-f]=u)}else{var k=t-+this._x.call(null,v.data),m=i-+this._y.call(null,v.data),M=e-+this._z.call(null,v.data),j=k*k+m*m+M*M;if(j<n){var q=Math.sqrt(n=j);c=t-q,x=i-q,w=e-q,d=t+q,p=i+q,z=e+q,s=v.data}}return s},w=function(t){if(isNaN(r=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t))||isNaN(o=+this._z.call(null,t)))return this;var i,e,n,s,r,h,o,a,l,_,u,f,c,y,x,w=this._root,d=this._x0,p=this._y0,z=this._z0,N=this._x1,v=this._y1,g=this._z1;if(!w)return this;if(w.length)for(;;){if((u=r>=(a=(d+N)/2))?d=a:N=a,(f=h>=(l=(p+v)/2))?p=l:v=l,(c=o>=(_=(z+g)/2))?z=_:g=_,i=w,!(w=w[y=c<<2|f<<1|u]))return this;if(!w.length)break;(i[y+1&7]||i[y+2&7]||i[y+3&7]||i[y+4&7]||i[y+5&7]||i[y+6&7]||i[y+7&7])&&(e=i,x=y)}for(;w.data!==t;)if(n=w,!(w=w.next))return this;return(s=w.next)&&delete w.next,n?(s?n.next=s:delete n.next,this):i?(s?i[y]=s:delete i[y],(w=i[0]||i[1]||i[2]||i[3]||i[4]||i[5]||i[6]||i[7])&&w===(i[7]||i[6]||i[5]||i[4]||i[3]||i[2]||i[1]||i[0])&&!w.length&&(e?e[x]=w:this._root=w),this):(this._root=s,this)},d=function(){return this._root},p=function(){var t=0;return this.visit(function(i){if(!i.length)do{++t}while(i=i.next)}),t},z=function(t){var i,e,n,s,r,h,o,a,l=[],_=this._root;for(_&&l.push(new y(_,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=l.pop();)if(!t(_=i.node,n=i.x0,s=i.y0,r=i.z0,h=i.x1,o=i.y1,a=i.z1)&&_.length){var u=(n+h)/2,f=(s+o)/2,c=(r+a)/2;(e=_[7])&&l.push(new y(e,u,f,c,h,o,a)),(e=_[6])&&l.push(new y(e,n,f,c,u,o,a)),(e=_[5])&&l.push(new y(e,u,s,c,h,f,a)),(e=_[4])&&l.push(new y(e,n,s,c,u,f,a)),(e=_[3])&&l.push(new y(e,u,f,r,h,o,c)),(e=_[2])&&l.push(new y(e,n,f,r,u,o,c)),(e=_[1])&&l.push(new y(e,u,s,r,h,f,c)),(e=_[0])&&l.push(new y(e,n,s,r,u,f,c))}return this},N=function(t){var i,e=[],n=[];for(this._root&&e.push(new y(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=e.pop();){var s=i.node;if(s.length){var r,h=i.x0,o=i.y0,a=i.z0,l=i.x1,_=i.y1,u=i.z1,f=(h+l)/2,c=(o+_)/2,x=(a+u)/2;(r=s[0])&&e.push(new y(r,h,o,a,f,c,x)),(r=s[1])&&e.push(new y(r,f,o,a,l,c,x)),(r=s[2])&&e.push(new y(r,h,c,a,f,_,x)),(r=s[3])&&e.push(new y(r,f,c,a,l,_,x)),(r=s[4])&&e.push(new y(r,h,o,x,f,c,u)),(r=s[5])&&e.push(new y(r,f,o,x,l,c,u)),(r=s[6])&&e.push(new y(r,h,c,x,f,_,u)),(r=s[7])&&e.push(new y(r,f,c,x,l,_,u))}n.push(i)}for(;i=n.pop();)t(i.node,i.x0,i.y0,i.z0,i.x1,i.y1,i.z1);return this},v=function(t){return arguments.length?(this._x=t,this):this._x},g=function(t){return arguments.length?(this._y=t,this):this._y},A=function(t){return arguments.length?(this._z=t,this):this._z},b=o.prototype=a.prototype;b.copy=function(){var t,i,e=new a(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return e;if(!n.length)return e._root=l(n),e;for(t=[{source:n,target:e._root=new Array(8)}];n=t.pop();)for(var s=0;s<8;++s)(i=n.source[s])&&(i.length?t.push({source:i,target:n.target[s]=new Array(8)}):n.target[s]=l(i));return e},b.add=_,b.addAll=e,b.cover=u,b.data=f,b.extent=c,b.find=x,b.remove=w,b.removeAll=n,b.root=d,b.size=p,b.visit=z,b.visitAfter=N,b.x=v,b.y=g,b.z=A,t.octree=o,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-octree",
"version": "0.1.0",
"version": "0.1.1",
"description": "Three-dimensional recursive spatial subdivision.",

@@ -5,0 +5,0 @@ "keywords": [

# d3-octree
Modified version of D3's [Quadtree](https://github.com/d3/d3-octree), to use with three dimensional data structures, by adding the z coordinate.
Ported version of D3's [Quadtree](https://github.com/d3/d3-quadtree), to use with three dimensional data structures, by adding the z coordinate.
A [octree](https://en.wikipedia.org/wiki/Octree) recursively partitions three-dimensional space into cubes, dividing each cube into eight equally-sized cubes. Each distinct point exists in a unique leaf [node](#nodes); coincident points are represented by a linked list. Octrees can accelerate various spatial operations, such as the [Barnes–Hut approximation](https://en.wikipedia.org/wiki/Barnes–Hut_simulation) for computing many-body forces, collision detection, and searching for nearby points.
An [octree](https://en.wikipedia.org/wiki/Octree) recursively partitions three-dimensional space into cubes, dividing each cube into eight equally-sized cubes. Each distinct point exists in a unique leaf [node](#nodes); coincident points are represented by a linked list. Octrees can accelerate various spatial operations, such as the [Barnes–Hut approximation](https://en.wikipedia.org/wiki/Barnes–Hut_simulation) for computing many-body forces, collision detection, and searching for nearby points.

@@ -158,3 +158,3 @@ ## Installing

Internal nodes of the octree are represented as four-element arrays in left-to-right, top-to-bottom, front-to-back order:
Internal nodes of the octree are represented as eight-element arrays in left-to-right, top-to-bottom, front-to-back order:

@@ -161,0 +161,0 @@ * `0` - the top-left-front octant, if any.

Sorry, the diff of this file is not supported yet

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