69 $currentBlock = $start->floor();
71 $directionVector = $end->subtractVector($start)->normalize();
72 if($directionVector->lengthSquared() <= 0){
73 throw new \InvalidArgumentException(
"Start and end points are the same, giving a zero direction vector");
76 $radius = $start->distance($end);
78 $stepX = $directionVector->x <=> 0;
79 $stepY = $directionVector->y <=> 0;
80 $stepZ = $directionVector->z <=> 0;
84 $tMaxX = self::distanceFactorToBoundary($start->x, $directionVector->x);
85 $tMaxY = self::distanceFactorToBoundary($start->y, $directionVector->y);
86 $tMaxZ = self::distanceFactorToBoundary($start->z, $directionVector->z);
89 $tDeltaX = floatval($directionVector->x) === 0.0 ? 0 : $stepX / $directionVector->x;
90 $tDeltaY = floatval($directionVector->y) === 0.0 ? 0 : $stepY / $directionVector->y;
91 $tDeltaZ = floatval($directionVector->z) === 0.0 ? 0 : $stepZ / $directionVector->z;
99 if($tMaxX < $tMaxY and $tMaxX < $tMaxZ){
100 if($tMaxX > $radius){
103 $currentBlock = $currentBlock->add($stepX, 0, 0);
105 }elseif($tMaxY < $tMaxZ){
106 if($tMaxY > $radius){
109 $currentBlock = $currentBlock->add(0, $stepY, 0);
112 if($tMaxZ > $radius){
115 $currentBlock = $currentBlock->add(0, 0, $stepZ);