如何制作八叉树3D对象?

时间:2019-05-19 18:10:18

标签: java processing

为什么在此代码中等于1之前不能将一个多维数据集划分为几个多维数据集?

我首先有一个用于绘制多维数据集的类框,第二个八叉树,我想将多维数据集划分为几个部分,我已经测试了该框的大小是否等于一个,否则我将进行划分

class Quadtree {   
   Box boundry;  
   int capacity; 
 // max no. of points   
   ArrayList <Point> points ;  
   boolean divide = false;   
   Quadtree northeast;    
   Quadtree northwest;   
   Quadtree southeast;   
   Quadtree southwest;

   public Quadtree (Rectangle rect, int cap) {
      this.boundry = rect;
      this.capacity = cap;
      points = new ArrayList<Point>();   }

   public boolean insert (Point p) {
      if(this.boundry.radius == 1.0)
         return false;
      else{
         if(!this.divide){
            insert(p);
            this.subDivide();
     }
    return true;

    }   }   
   public void  subDivide () {
       PVector x = this.boundry.bottomRight;
       PVector y= this.boundry.bottomRight;
       float w = this.boundry.radius;
       float h = this.boundry.radius;

       this.northeast = new Quadtree(new Box (x.copy().add(new PVector(0, 0, 0)), w/2.0));
       this.northwest = new Quadtree(new Box (x.copy().add(new PVector(w/2, 0, 0)), w/2)); 
       this.southeast = new Quadtree(new Box (x.copy().add(new PVector(0, h/2, 0)), w/2));

       this.southwest = new Quadtree(new Box (x.copy().add(new PVector(w/2, h/2, 0)),w/2));
       this.divide = true;   }

我进入了无限循环,尽管我对它是否被除以了一个条件,但在此之前,他不会对立方体进行除法,而是在其他地方绘制立方体。实际上,我不知道如何格式化代码或我如何将多维数据集拆分为3d空间中的多维数据集集..在那方面我没有找到任何帮助我的

0 个答案:

没有答案