Update EntityAPI.php

This commit is contained in:
ArkQuark 2022-10-20 23:35:02 +03:00
parent 7ea63bdceb
commit 83b7bc4b39
11 changed files with 380 additions and 57 deletions

View file

@ -535,12 +535,23 @@ class Utils{
public static function round($number){
return round($number, 0, PHP_ROUND_HALF_DOWN);
}
public static function distance($pos1, $pos2){
if($pos1 instanceof Vector3){
$pos1 = $pos1->toArray();
}
if($pos2 instanceof Vector3){
$pos2 = $pos2->toArray();
}
return sqrt(pow($pos1["x"] - $pos2["x"], 2) + pow($pos1["y"] - $pos2["y"], 2) + pow($pos1["z"] - $pos2["z"], 2));
}
public static function angle3D($pos1, $pos2){
if($pos1 instanceof Vector3){
$pos1 = $pos1->toArray();
}
if($pos2 instanceof Vector3){
$pos2 = $pos2->toArray();
}
$X = $pos1["x"] - $pos2["x"];
$Z = $pos1["z"] - $pos2["z"];
$dXZ = sqrt(pow($X, 2) + pow($Z, 2));