GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
AxisAlignedBB Class Reference

Public Member Functions

 __construct ($minX, $minY, $minZ, $maxX, $maxY, $maxZ)
 
 setBounds ($minX, $minY, $minZ, $maxX, $maxY, $maxZ)
 
 addCoord ($x, $y, $z)
 
 grow ($x, $y, $z)
 
 expand ($x, $y, $z)
 
 offset ($x, $y, $z)
 
 shrink ($x, $y, $z)
 
 contract ($x, $y, $z)
 
 setBB (AxisAlignedBB $bb)
 
 getOffsetBoundingBox ($x, $y, $z)
 
 calculateXOffset (AxisAlignedBB $bb, $x)
 
 calculateYOffset (AxisAlignedBB $bb, $y)
 
 calculateZOffset (AxisAlignedBB $bb, $z)
 
 intersectsWith (AxisAlignedBB $bb)
 
 isVectorInside (Vector3 $vector)
 
 getAverageEdgeLength ()
 
 isVectorInYZ (Vector3 $vector)
 
 isVectorInXZ (Vector3 $vector)
 
 isVectorInXY (Vector3 $vector)
 
 calculateIntercept (Vector3 $pos1, Vector3 $pos2)
 
 __toString ()
 

Data Fields

 $minX
 
 $minY
 
 $minZ
 
 $maxX
 
 $maxY
 
 $maxZ
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $minX,
  $minY,
  $minZ,
  $maxX,
  $maxY,
  $maxZ 
)

AxisAlignedBB constructor.

Parameters
$minX
$minY
$minZ
$maxX
$maxY
$maxZ
45  {
46  $this->minX = $minX;
47  $this->minY = $minY;
48  $this->minZ = $minZ;
49  $this->maxX = $maxX;
50  $this->maxY = $maxY;
51  $this->maxZ = $maxZ;
52  }

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string
456  {
457  return "AxisAlignedBB({$this->minX}, {$this->minY}, {$this->minZ}, {$this->maxX}, {$this->maxY}, {$this->maxZ})";
458  }

◆ addCoord()

addCoord (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
AxisAlignedBB
82  {
89 
90  if($x < 0){
91  $minX += $x;
92  }elseif($x > 0){
93  $maxX += $x;
94  }
95 
96  if($y < 0){
97  $minY += $y;
98  }elseif($y > 0){
99  $maxY += $y;
100  }
101 
102  if($z < 0){
103  $minZ += $z;
104  }elseif($z > 0){
105  $maxZ += $z;
106  }
107 
108  return new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
109  }

◆ calculateIntercept()

calculateIntercept ( Vector3  $pos1,
Vector3  $pos2 
)
Parameters
Vector3$pos1
Vector3$pos2
Returns
MovingObjectPosition
371  {
372  $v1 = $pos1->getIntermediateWithXValue($pos2, $this->minX);
373  $v2 = $pos1->getIntermediateWithXValue($pos2, $this->maxX);
374  $v3 = $pos1->getIntermediateWithYValue($pos2, $this->minY);
375  $v4 = $pos1->getIntermediateWithYValue($pos2, $this->maxY);
376  $v5 = $pos1->getIntermediateWithZValue($pos2, $this->minZ);
377  $v6 = $pos1->getIntermediateWithZValue($pos2, $this->maxZ);
378 
379  if($v1 !== null and !$this->isVectorInYZ($v1)){
380  $v1 = null;
381  }
382 
383  if($v2 !== null and !$this->isVectorInYZ($v2)){
384  $v2 = null;
385  }
386 
387  if($v3 !== null and !$this->isVectorInXZ($v3)){
388  $v3 = null;
389  }
390 
391  if($v4 !== null and !$this->isVectorInXZ($v4)){
392  $v4 = null;
393  }
394 
395  if($v5 !== null and !$this->isVectorInXY($v5)){
396  $v5 = null;
397  }
398 
399  if($v6 !== null and !$this->isVectorInXY($v6)){
400  $v6 = null;
401  }
402 
403  $vector = null;
404 
405 
406  if($v1 !== null and ($vector === null or $pos1->distanceSquared($v1) < $pos1->distanceSquared($vector))){
407  $vector = $v1;
408  }
409 
410  if($v2 !== null and ($vector === null or $pos1->distanceSquared($v2) < $pos1->distanceSquared($vector))){
411  $vector = $v2;
412  }
413 
414  if($v3 !== null and ($vector === null or $pos1->distanceSquared($v3) < $pos1->distanceSquared($vector))){
415  $vector = $v3;
416  }
417 
418  if($v4 !== null and ($vector === null or $pos1->distanceSquared($v4) < $pos1->distanceSquared($vector))){
419  $vector = $v4;
420  }
421 
422  if($v5 !== null and ($vector === null or $pos1->distanceSquared($v5) < $pos1->distanceSquared($vector))){
423  $vector = $v5;
424  }
425 
426  if($v6 !== null and ($vector === null or $pos1->distanceSquared($v6) < $pos1->distanceSquared($vector))){
427  $vector = $v6;
428  }
429 
430  if($vector === null){
431  return null;
432  }
433 
434  $f = -1;
435 
436  if($vector === $v1){
437  $f = 4;
438  }elseif($vector === $v2){
439  $f = 5;
440  }elseif($vector === $v3){
441  $f = 0;
442  }elseif($vector === $v4){
443  $f = 1;
444  }elseif($vector === $v5){
445  $f = 2;
446  }elseif($vector === $v6){
447  $f = 3;
448  }
449 
450  return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector);
451  }

◆ calculateXOffset()

calculateXOffset ( AxisAlignedBB  $bb,
  $x 
)
Parameters
AxisAlignedBB$bb
$x
Returns
mixed
219  {
220  if($bb->maxY <= $this->minY or $bb->minY >= $this->maxY){
221  return $x;
222  }
223  if($bb->maxZ <= $this->minZ or $bb->minZ >= $this->maxZ){
224  return $x;
225  }
226  if($x > 0 and $bb->maxX <= $this->minX){
227  $x1 = $this->minX - $bb->maxX;
228  if($x1 < $x){
229  $x = $x1;
230  }
231  }
232  if($x < 0 and $bb->minX >= $this->maxX){
233  $x2 = $this->maxX - $bb->minX;
234  if($x2 > $x){
235  $x = $x2;
236  }
237  }
238 
239  return $x;
240  }

◆ calculateYOffset()

calculateYOffset ( AxisAlignedBB  $bb,
  $y 
)
Parameters
AxisAlignedBB$bb
$y
Returns
mixed
248  {
249  if($bb->maxX <= $this->minX or $bb->minX >= $this->maxX){
250  return $y;
251  }
252  if($bb->maxZ <= $this->minZ or $bb->minZ >= $this->maxZ){
253  return $y;
254  }
255  if($y > 0 and $bb->maxY <= $this->minY){
256  $y1 = $this->minY - $bb->maxY;
257  if($y1 < $y){
258  $y = $y1;
259  }
260  }
261  if($y < 0 and $bb->minY >= $this->maxY){
262  $y2 = $this->maxY - $bb->minY;
263  if($y2 > $y){
264  $y = $y2;
265  }
266  }
267 
268  return $y;
269  }

◆ calculateZOffset()

calculateZOffset ( AxisAlignedBB  $bb,
  $z 
)
Parameters
AxisAlignedBB$bb
$z
Returns
mixed
277  {
278  if($bb->maxX <= $this->minX or $bb->minX >= $this->maxX){
279  return $z;
280  }
281  if($bb->maxY <= $this->minY or $bb->minY >= $this->maxY){
282  return $z;
283  }
284  if($z > 0 and $bb->maxZ <= $this->minZ){
285  $z1 = $this->minZ - $bb->maxZ;
286  if($z1 < $z){
287  $z = $z1;
288  }
289  }
290  if($z < 0 and $bb->minZ >= $this->maxZ){
291  $z2 = $this->maxZ - $bb->minZ;
292  if($z2 > $z){
293  $z = $z2;
294  }
295  }
296 
297  return $z;
298  }

◆ contract()

contract (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
$this
176  {
177  $this->minX += $x;
178  $this->minY += $y;
179  $this->minZ += $z;
180  $this->maxX -= $x;
181  $this->maxY -= $y;
182  $this->maxZ -= $z;
183 
184  return $this;
185  }

◆ expand()

expand (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
$this
129  {
130  $this->minX -= $x;
131  $this->minY -= $y;
132  $this->minZ -= $z;
133  $this->maxX += $x;
134  $this->maxY += $y;
135  $this->maxZ += $z;
136 
137  return $this;
138  }

◆ getAverageEdgeLength()

getAverageEdgeLength ( )
Returns
float|int
334  {
335  return ($this->maxX - $this->minX + $this->maxY - $this->minY + $this->maxZ - $this->minZ) / 3;
336  }

◆ getOffsetBoundingBox()

getOffsetBoundingBox (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
AxisAlignedBB
209  {
210  return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z);
211  }

◆ grow()

grow (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
AxisAlignedBB
118  {
119  return new AxisAlignedBB($this->minX - $x, $this->minY - $y, $this->minZ - $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z);
120  }

◆ intersectsWith()

intersectsWith ( AxisAlignedBB  $bb)
Parameters
AxisAlignedBB$bb
Returns
bool
305  {
306  if($bb->maxX > $this->minX and $bb->minX < $this->maxX){
307  if($bb->maxY > $this->minY and $bb->minY < $this->maxY){
308  return $bb->maxZ > $this->minZ and $bb->minZ < $this->maxZ;
309  }
310  }
311 
312  return false;
313  }

◆ isVectorInside()

isVectorInside ( Vector3  $vector)
Parameters
Vector3$vector
Returns
bool
320  {
321  if($vector->x <= $this->minX or $vector->x >= $this->maxX){
322  return false;
323  }
324  if($vector->y <= $this->minY or $vector->y >= $this->maxY){
325  return false;
326  }
327 
328  return $vector->z > $this->minZ and $vector->z < $this->maxZ;
329  }

◆ isVectorInXY()

isVectorInXY ( Vector3  $vector)
Parameters
Vector3$vector
Returns
bool
361  {
362  return $vector->x >= $this->minX and $vector->x <= $this->maxX and $vector->y >= $this->minY and $vector->y <= $this->maxY;
363  }

◆ isVectorInXZ()

isVectorInXZ ( Vector3  $vector)
Parameters
Vector3$vector
Returns
bool
352  {
353  return $vector->x >= $this->minX and $vector->x <= $this->maxX and $vector->z >= $this->minZ and $vector->z <= $this->maxZ;
354  }

◆ isVectorInYZ()

isVectorInYZ ( Vector3  $vector)
Parameters
Vector3$vector
Returns
bool
343  {
344  return $vector->y >= $this->minY and $vector->y <= $this->maxY and $vector->z >= $this->minZ and $vector->z <= $this->maxZ;
345  }

◆ offset()

offset (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
$this
147  {
148  $this->minX += $x;
149  $this->minY += $y;
150  $this->minZ += $z;
151  $this->maxX += $x;
152  $this->maxY += $y;
153  $this->maxZ += $z;
154 
155  return $this;
156  }

◆ setBB()

setBB ( AxisAlignedBB  $bb)
Parameters
AxisAlignedBB$bb
Returns
$this
192  {
193  $this->minX = $bb->minX;
194  $this->minY = $bb->minY;
195  $this->minZ = $bb->minZ;
196  $this->maxX = $bb->maxX;
197  $this->maxY = $bb->maxY;
198  $this->maxZ = $bb->maxZ;
199  return $this;
200  }

◆ setBounds()

setBounds (   $minX,
  $minY,
  $minZ,
  $maxX,
  $maxY,
  $maxZ 
)
Parameters
$minX
$minY
$minZ
$maxX
$maxY
$maxZ
Returns
$this
64  {
65  $this->minX = $minX;
66  $this->minY = $minY;
67  $this->minZ = $minZ;
68  $this->maxX = $maxX;
69  $this->maxY = $maxY;
70  $this->maxZ = $maxZ;
71 
72  return $this;
73  }

◆ shrink()

shrink (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
AxisAlignedBB
165  {
166  return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX - $x, $this->maxY - $y, $this->maxZ - $z);
167  }

Field Documentation

◆ $maxX

$maxX

◆ $maxY

$maxY

◆ $maxZ

$maxZ

◆ $minX

$minX

◆ $minY

$minY

◆ $minZ

$minZ

The documentation for this class was generated from the following file: