GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Noise Class Reference

Public Member Functions

 getNoise2D ($x, $z)
 
 getNoise3D ($x, $y, $z)
 
 noise2D ($x, $z, $normalized=false)
 
 noise3D ($x, $y, $z, $normalized=false)
 
 setOffset ($x, $y, $z)
 

Static Public Member Functions

static floor ($x)
 
static fade ($x)
 
static lerp ($x, $y, $z)
 
static linearLerp ($x, $x1, $x2, $q0, $q1)
 
static bilinearLerp ($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2)
 
static trilinearLerp ($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2)
 
static grad ($hash, $x, $y, $z)
 

Protected Attributes

 $perm = []
 
 $offsetX = 0
 
 $offsetY = 0
 
 $offsetZ = 0
 
 $octaves = 8
 
 $persistence
 
 $expansion
 

Member Function Documentation

◆ bilinearLerp()

static bilinearLerp (   $x,
  $y,
  $q00,
  $q01,
  $q10,
  $q11,
  $x1,
  $x2,
  $y1,
  $y2 
)
static
Parameters
$x
$y
$q00
$q01
$q10
$q11
$x1
$x2
$y1
$y2
Returns
float|int
94  {
95  $dx1 = (($x2 - $x) / ($x2 - $x1));
96  $dx2 = (($x - $x1) / ($x2 - $x1));
97 
98  return (($y2 - $y) / ($y2 - $y1)) * (
99  $dx1 * $q00 + $dx2 * $q10
100  ) + (($y - $y1) / ($y2 - $y1)) * (
101  $dx1 * $q01 + $dx2 * $q11
102  );
103  }

◆ fade()

static fade (   $x)
static
Parameters
$x
Returns
mixed
52  {
53  return $x * $x * $x * ($x * ($x * 6 - 15) + 10);
54  }

◆ floor()

static floor (   $x)
static
Parameters
$x
Returns
int
43  {
44  return $x >= 0 ? (int) $x : (int) ($x - 1);
45  }

◆ getNoise2D()

getNoise2D (   $x,
  $z 
)
abstract
Parameters
$x
$z
Returns
mixed

◆ getNoise3D()

getNoise3D (   $x,
  $y,
  $z 
)
abstract
Parameters
$x
$y
$z
Returns
mixed

◆ grad()

static grad (   $hash,
  $x,
  $y,
  $z 
)
static
Parameters
$hash
$x
$y
$z
Returns
mixed
155  {
156  $hash &= 15;
157  $u = $hash < 8 ? $x : $y;
158  $v = $hash < 4 ? $y : (($hash === 12 or $hash === 14) ? $x : $z);
159 
160  return (($hash & 1) === 0 ? $u : -$u) + (($hash & 2) === 0 ? $v : -$v);
161  }

◆ lerp()

static lerp (   $x,
  $y,
  $z 
)
static
Parameters
$x
$y
$z
Returns
mixed
63  {
64  return $y + $x * ($z - $y);
65  }

◆ linearLerp()

static linearLerp (   $x,
  $x1,
  $x2,
  $q0,
  $q1 
)
static
Parameters
$x
$x1
$x2
$q0
$q1
Returns
float|int
76  {
77  return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $q1;
78  }

◆ noise2D()

noise2D (   $x,
  $z,
  $normalized = false 
)
Parameters
$x
$z
bool$normalized
Returns
int
187  {
188  $result = 0;
189  $amp = 1;
190  $freq = 1;
191  $max = 0;
192 
193  $x *= $this->expansion;
194  $z *= $this->expansion;
195 
196  for($i = 0; $i < $this->octaves; ++$i){
197  $result += $this->getNoise2D($x * $freq, $z * $freq) * $amp;
198  $max += $amp;
199  $freq *= 2;
200  $amp *= $this->persistence;
201  }
202 
203  if($normalized === true){
204  $result /= $max;
205  }
206 
207  return $result;
208  }

◆ noise3D()

noise3D (   $x,
  $y,
  $z,
  $normalized = false 
)
Parameters
$x
$y
$z
bool$normalized
Returns
int
218  {
219  $result = 0;
220  $amp = 1;
221  $freq = 1;
222  $max = 0;
223 
224  $x *= $this->expansion;
225  $y *= $this->expansion;
226  $z *= $this->expansion;
227 
228  for($i = 0; $i < $this->octaves; ++$i){
229  $result += $this->getNoise3D($x * $freq, $y * $freq, $z * $freq) * $amp;
230  $max += $amp;
231  $freq *= 2;
232  $amp *= $this->persistence;
233  }
234 
235  if($normalized === true){
236  $result /= $max;
237  }
238 
239  return $result;
240  }

◆ setOffset()

setOffset (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
247  {
248  $this->offsetX = $x;
249  $this->offsetY = $y;
250  $this->offsetZ = $z;
251  }

◆ trilinearLerp()

static trilinearLerp (   $x,
  $y,
  $z,
  $q000,
  $q001,
  $q010,
  $q011,
  $q100,
  $q101,
  $q110,
  $q111,
  $x1,
  $x2,
  $y1,
  $y2,
  $z1,
  $z2 
)
static
Parameters
$x
$y
$z
$q000
$q001
$q010
$q011
$q100
$q101
$q110
$q111
$x1
$x2
$y1
$y2
$z1
$z2
Returns
float|int
126  {
127  $dx1 = (($x2 - $x) / ($x2 - $x1));
128  $dx2 = (($x - $x1) / ($x2 - $x1));
129  $dy1 = (($y2 - $y) / ($y2 - $y1));
130  $dy2 = (($y - $y1) / ($y2 - $y1));
131 
132  return (($z2 - $z) / ($z2 - $z1)) * (
133  $dy1 * (
134  $dx1 * $q000 + $dx2 * $q100
135  ) + $dy2 * (
136  $dx1 * $q001 + $dx2 * $q101
137  )
138  ) + (($z - $z1) / ($z2 - $z1)) * (
139  $dy1 * (
140  $dx1 * $q010 + $dx2 * $q110
141  ) + $dy2 * (
142  $dx1 * $q011 + $dx2 * $q111
143  )
144  );
145  }

Field Documentation

◆ $expansion

$expansion
protected

◆ $octaves

$octaves = 8
protected

◆ $offsetX

$offsetX = 0
protected

◆ $offsetY

$offsetY = 0
protected

◆ $offsetZ

$offsetZ = 0
protected

◆ $perm

$perm = []
protected

◆ $persistence

$persistence
protected

The documentation for this class was generated from the following file: