Пример #1
0
 public AllignedBox UnionWith(AllignedBox other)
 {
     double newx1 = Math.Min(centre.X - width / 2, other.centre.X - other.width / 2);
     double newx2 = Math.Max(centre.X + width / 2, other.centre.X + other.width / 2);
     double newy1 = Math.Min(centre.Y - height / 2, other.centre.Y - other.height / 2);
     double newy2 = Math.Max(centre.Y + height / 2, other.centre.Y + other.height / 2);
     double newz1 = Math.Min(centre.Z - depth / 2, other.centre.Z - other.depth / 2);
     double newz2 = Math.Max(centre.Z + depth / 2, other.centre.Z + other.depth / 2);
     Point newcentre = new Point();
     newcentre.X = (newx2 + newx1) / 2;
     newcentre.Y = (newy2 + newy1) / 2;
     newcentre.Z = (newz2 + newz1) / 2;
     double newwidth = newx2 - newx1;
     double newheight = newy2 - newy1;
     double newdepth = newz2 - newz1;
     AllignedBox boxret = new AllignedBox(newcentre, newwidth, newheight, newdepth);
     return boxret;
 }
Пример #2
0
 public AllignedBox(AllignedBox other)
     : this(new Point(other.centre.X, other.centre.Y, other.centre.Z), other.width, other.height, other.depth)
 {
 }
Пример #3
0
 public void Increase(AllignedBox stretchby)
 {
     double newx1 = Math.Min(centre.X - width / 2, stretchby.centre.X - stretchby.width / 2);
     double newx2 = Math.Max(centre.X + width / 2, stretchby.centre.X + stretchby.width / 2);
     double newy1 = Math.Min(centre.Y - height / 2, stretchby.centre.Y - stretchby.height / 2);
     double newy2 = Math.Max(centre.Y + height / 2, stretchby.centre.Y + stretchby.height / 2);
     double newz1 = Math.Min(centre.Z - depth / 2, stretchby.centre.Z - stretchby.depth / 2);
     double newz2 = Math.Max(centre.Z + depth / 2, stretchby.centre.Z + stretchby.depth / 2);
     centre.X = (newx2 + newx1) / 2;
     centre.Y = (newy2 + newy1) / 2;
     centre.Z = (newz2 + newz1) / 2;
     width = newx2 - newx1;
     height = newy2 - newy1;
     depth = newz2 - newz1;
     width2e = width / 2 + ToyTracer.EPSILON;
     height2e = height / 2 + ToyTracer.EPSILON;
     depth2e = depth / 2 + ToyTracer.EPSILON;
     xmin = centre.X - width / 2;
     ymin = centre.Y - height / 2;
     zmin = centre.Z - depth / 2;
     xmax = centre.X + width / 2;
     ymax = centre.Y + height / 2;
     zmax = centre.Z + depth / 2;
 }
Пример #4
0
 public bool Disjoint(AllignedBox other)
 {
     double widthav = (width + other.width) / 2;
     if (Math.Abs(centre.X - other.centre.X) > widthav)
         return true;
     double heightav = (height + other.height) / 2;
     if (Math.Abs(centre.Y - other.centre.Y) > heightav)
         return true;
     double depthav = (depth + other.depth) / 2;
     if (Math.Abs(centre.Z - other.centre.Z) > widthav)
         return true;
     return false;
 }