On 08.01.2017 10:55, Ryan Joseph wrote:
> I’m going to attempt to translate a perlin noise function (from 
> https://gist.github.com/Flafla2/f0260a861be0ebdeef76) but there are a few 
> things that stopped me from starting.
> 
> 1) What is & doing in this assignment? I see this many places in assignments.
> 
> int h = hash & 15;

That's an "and".

> 2) % is the mod operator in pascal right? So what is the modular assignment 
> %=? num = num mod repeat?
> 
> p[x] = permutation[x%256];
> 
> if (repeat > 0) num %= repeat;

Correct for both.

> 3) Adding the tertiary operator?
> 
> return ((h&1) == 0 ? u : -u)+((h&2) == 0 ? v : -v);

if h and 1 = 0 then
  result := u
else
  result := -u;
if h and 2 = 0 then
  result := result + v
else
  result := result - v;

> Here’s an easier example. Did I do that correctly?
> 
> if h < 8 then
>       u := x
> else
>       u := y;
> 
> double u = h < 8 /* 0b1000 */ ? x : y;
> 

Correct.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to