mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Added more Vector math
This commit is contained in:
parent
4284211bd1
commit
808f5473d0
@ -86,6 +86,14 @@ class Vector2{
|
||||
public function abs(){
|
||||
return new Vector2(abs($this->x), abs($this->y));
|
||||
}
|
||||
|
||||
public function multiply($number){
|
||||
return new Vector2($this->x * $number, $this->y * $number);
|
||||
}
|
||||
|
||||
public function divide($number){
|
||||
return new Vector2($this->x / $number, $this->y / $number);
|
||||
}
|
||||
|
||||
public function distance($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
|
@ -97,6 +97,14 @@ class Vector3{
|
||||
return $this->add(-$x, -$y, -$z);
|
||||
}
|
||||
}
|
||||
|
||||
public function multiply($number){
|
||||
return new Vector3($this->x * $number, $this->y * $number, $this->z * $number);
|
||||
}
|
||||
|
||||
public function divide($number){
|
||||
return new Vector3($this->x / $number, $this->y / $number, $this->z / $number);
|
||||
}
|
||||
|
||||
public function ceil(){
|
||||
return new Vector3((int) ($this->x + 1), (int) ($this->y + 1), (int) ($this->z + 1));
|
||||
|
34
src/math/VectorMath.php
Normal file
34
src/math/VectorMath.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class VectorMath{
|
||||
|
||||
public static function getDirection2D($azimuth){
|
||||
return new Vector2(cos($azimuth), sin($azimuth));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user