Perlin noise: Difference between revisions

Content added Content deleted
m (Aligning texr.)
(remove non-breakable whitespaces)
Line 1: Line 1:
{{task}}
{{task}}


The   '''[[wp:Perlin noise|Perlin noise]]'''   is a kind of   [[wp:gradient noise|gradient noise]]   invented by   [[wp:Ken Perlin|Ken Perlin]]   around the end of the twentieth century and still currently heavily used in   [[wp:computer graphics|computer graphics]],   most notably to procedurally generate textures or heightmaps.
The '''[[wp:Perlin noise|Perlin noise]]''' is a kind of [[wp:gradient noise|gradient noise]] invented by [[wp:Ken Perlin|Ken Perlin]] around the end of the twentieth century and still currently heavily used in [[wp:computer graphics|computer graphics]], most notably to procedurally generate textures or heightmaps.


The Perlin noise is basically a &nbsp; [[random numbers|pseudo-random]] &nbsp; mapping of &nbsp; <big><big><math>\R^d</math></big></big> &nbsp; into &nbsp; <big><big><math>\R</math></big></big> &nbsp; with an integer &nbsp; <big><math>d</math></big> &nbsp; which can be arbitrarily large but which is usually &nbsp; 2, &nbsp; 3, &nbsp; or &nbsp; 4.
The Perlin noise is basically a [[random numbers|pseudo-random]] mapping of <big><big><math>\R^d</math></big></big> into <big><big><math>\R</math></big></big> with an integer <big><math>d</math></big> which can be arbitrarily large but which is usually 2, 3, or 4.

Either by using a dedicated library or by implementing the algorithm, show that the Perlin noise &nbsp; (as defined in 2002 in the Java implementation below) &nbsp; of the point in 3D-space with coordinates &nbsp; &nbsp; 3.14, &nbsp; 42, &nbsp; 7 &nbsp; &nbsp; is &nbsp; &nbsp; 0.13691995878400012.


Either by using a dedicated library or by implementing the algorithm, show that the Perlin noise (as defined in 2002 in the Java implementation below) of the point in 3D-space with coordinates 3.14, 42, 7 is 0.13691995878400012.


''Note: this result assumes 64 bit IEEE-754 floating point calculations. If your language uses a different floating point representation, make a note of it and calculate the value accurate to 15 decimal places, or your languages accuracy threshold if it is less. Trailing zeros need not be displayed.''
''Note: this result assumes 64 bit IEEE-754 floating point calculations. If your language uses a different floating point representation, make a note of it and calculate the value accurate to 15 decimal places, or your languages accuracy threshold if it is less. Trailing zeros need not be displayed.''
Line 2,146: Line 2,145:
=={{header|REXX}}==
=={{header|REXX}}==
{{trans|Go}}
{{trans|Go}}
Programming note: &nbsp; the REXX operator &nbsp; <big><b> '''//''' </b></big> &nbsp; is the remainder for division &nbsp; (not modulus), &nbsp; so the absolute value of the
Programming note: the REXX operator <big><b> '''//''' </b></big> is the remainder for division (not modulus), so the absolute value of the
<br>remainder is used for this task.
<br>remainder is used for this task.


Line 2,196: Line 2,195:
lerp(u, grad( pick(ab+1), x , ym, zm ), ,
lerp(u, grad( pick(ab+1), x , ym, zm ), ,
grad( pick(bb+1), xm, ym, zm )))) /1</syntaxhighlight>
grad( pick(bb+1), xm, ym, zm )))) /1</syntaxhighlight>
{{out|output|text=&nbsp; when using the internal default inputs:}}
{{out|output|text=when using the internal default inputs:}}


(Output note: &nbsp; this REXX program uses '''100''' decimal digit precision, but '''20''' decimal digits would've been adequate.)
(Output note: this REXX program uses '''100''' decimal digit precision, but '''20''' decimal digits would've been adequate.)


(Note that REXX uses &nbsp; ''decimal'' &nbsp; floating point, &nbsp; not binary.)
(Note that REXX uses ''decimal'' floating point, not binary.)
<pre>
<pre>
Perlin noise for the 3D point [3.14 42 7] ───► 0.136919958784
Perlin noise for the 3D point [3.14 42 7] ───► 0.136919958784