phpdoc: populate missing parameter typeinfo

This commit is contained in:
Dylan K. Taylor
2020-01-11 21:53:24 +00:00
parent c329ff7d4f
commit 17720041a3
20 changed files with 260 additions and 3 deletions

View File

@ -46,22 +46,62 @@ abstract class Noise{
/** @var float */
protected $expansion;
/**
* @param float $x
*
* @return int
*/
public static function floor($x) : int{
return $x >= 0 ? (int) $x : (int) ($x - 1);
}
/**
* @param float $x
*
* @return float
*/
public static function fade($x){
return $x * $x * $x * ($x * ($x * 6 - 15) + 10);
}
/**
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
public static function lerp($x, $y, $z){
return $y + $x * ($z - $y);
}
/**
* @param float $x
* @param float $x1
* @param float $x2
* @param float $q0
* @param float $q1
*
* @return float
*/
public static function linearLerp($x, $x1, $x2, $q0, $q1){
return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $q1;
}
/**
* @param float $x
* @param float $y
* @param float $q00
* @param float $q01
* @param float $q10
* @param float $q11
* @param float $x1
* @param float $x2
* @param float $y1
* @param float $y2
*
* @return float
*/
public static function bilinearLerp($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2){
$dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($x2 - $x1));
@ -73,6 +113,27 @@ abstract class Noise{
);
}
/**
* @param float $x
* @param float $y
* @param float $z
* @param float $q000
* @param float $q001
* @param float $q010
* @param float $q011
* @param float $q100
* @param float $q101
* @param float $q110
* @param float $q111
* @param float $x1
* @param float $x2
* @param float $y1
* @param float $y2
* @param float $z1
* @param float $z2
*
* @return float
*/
public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2){
$dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($x2 - $x1));
@ -94,6 +155,14 @@ abstract class Noise{
);
}
/**
* @param int $hash
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
public static function grad($hash, $x, $y, $z){
$hash &= 15;
$u = $hash < 8 ? $x : $y;
@ -102,10 +171,30 @@ abstract class Noise{
return (($hash & 1) === 0 ? $u : -$u) + (($hash & 2) === 0 ? $v : -$v);
}
/**
* @param float $x
* @param float $z
*
* @return float
*/
abstract public function getNoise2D($x, $z);
/**
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
abstract public function getNoise3D($x, $y, $z);
/**
* @param float $x
* @param float $z
* @param bool $normalized
*
* @return float
*/
public function noise2D($x, $z, $normalized = false){
$result = 0;
$amp = 1;
@ -129,6 +218,14 @@ abstract class Noise{
return $result;
}
/**
* @param float $x
* @param float $y
* @param float $z
* @param bool $normalized
*
* @return float
*/
public function noise3D($x, $y, $z, $normalized = false){
$result = 0;
$amp = 1;
@ -304,6 +401,11 @@ abstract class Noise{
return $noiseArray;
}
/**
* @param float $x
* @param float $y
* @param float $z
*/
public function setOffset($x, $y, $z){
$this->offsetX = $x;
$this->offsetY = $y;

View File

@ -34,6 +34,12 @@ class Perlin extends Noise{
];
/**
* @param Random $random
* @param int $octaves
* @param float $persistence
* @param float $expansion
*/
public function __construct(Random $random, $octaves, $persistence, $expansion = 1){
$this->octaves = $octaves;
$this->persistence = $persistence;

View File

@ -83,6 +83,12 @@ class Simplex extends Perlin{
protected $offsetW;
/**
* @param Random $random
* @param int $octaves
* @param float $persistence
* @param float $expansion
*/
public function __construct(Random $random, $octaves, $persistence, $expansion = 1){
parent::__construct($random, $octaves, $persistence, $expansion);
$this->offsetW = $random->nextFloat() * 256;
@ -100,14 +106,38 @@ class Simplex extends Perlin{
self::$G44 = self::$G4 * 4.0 - 1.0;
}
/**
* @param int[] $g
* @param float $x
* @param float $y
*
* @return float
*/
protected static function dot2D($g, $x, $y){
return $g[0] * $x + $g[1] * $y;
}
/**
* @param int[] $g
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
protected static function dot3D($g, $x, $y, $z){
return $g[0] * $x + $g[1] * $y + $g[2] * $z;
}
/**
* @param int[] $g
* @param float $x
* @param float $y
* @param float $z
* @param float $w
*
* @return float
*/
protected static function dot4D($g, $x, $y, $z, $w){
return $g[0] * $x + $g[1] * $y + $g[2] * $z + $g[3] * $w;
}