mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
small tweaks
This commit is contained in:
parent
c41e31e237
commit
9f5304bdad
7 changed files with 52 additions and 47 deletions
|
|
@ -574,8 +574,17 @@ class Utils{
|
|||
/**
|
||||
* Euclidian distance, but without square roots
|
||||
*/
|
||||
public static function distance_noroot(Vector3 $pos1, Vector3 $pos2){
|
||||
return ($pos2->x - $pos1->x)*($pos2->x - $pos1->x) + ($pos2->z - $pos1->z)*($pos2->z - $pos1->z) + ($pos2->z - $pos1->z)*($pos2->z - $pos1->z);
|
||||
public static function distance_noroot($pos1, $pos2){
|
||||
if($pos1 instanceof Vector3){
|
||||
$pos1 = $pos1->toArray();
|
||||
}
|
||||
if($pos2 instanceof Vector3){
|
||||
$pos2 = $pos2->toArray();
|
||||
}
|
||||
$pX = ($pos1["x"] - $pos2["x"]);
|
||||
$pY = ($pos1["y"] - $pos2["y"]);
|
||||
$pZ = ($pos1["z"] - $pos2["z"]);
|
||||
return ($pX*$pX) + ($pY*$pY) + ($pZ*$pZ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue