|
 |
Thomas de Groot <tho### [at] degroot org> wrote:
> ...which reminds me to ask you (curiosity): how does
>
> #declare U = function (X, Y, Z) {(0.5 + atan2 (N(Z, X,Y,Z), N(X,
> X,Y,Z))/(2*pi))}
> #declare V = function (X, Y, Z) {(0.5 + asin(N(Y, X,Y,Z))/pi)}
>
> work? is puzzling, as far as atan2 and asin are concerned.
>
> --
> Thomas
I don't have the file accessible to me ATM, but IIRC, the N() function is
probably just a select () for whichever vector component is specified as the
first argument. (*)
Then the atan2 returns an angle between -pi and pi, based on z and x.
Dividing by tau gives values between -0.5 and 0.5, and then everything is
shifted to between 0 and 1.
asin returns an angle between -pi/2 and pi/2.
Dividing by pi gives values between -0.5 and 0.5, and then everything is shifted
to between 0 and 1.
(*) And the way THAT works, is taking the specified vector components and doing
something like x*(-1) + y*0 + z*(2). That should give you a -1, a 0, or a 2
depending on which cardinal vector is specified.
select () then returns one of three scalar values depending on what component it
spits out.
Post a reply to this message
|
 |