POV-Ray : Newsgroups : povray.bugreports : uv_mapping bug on cylinders : Re: uv_mapping bug on cylinders Server Time
8 Aug 2022 21:47:23 EDT (-0400)
  Re: uv_mapping bug on cylinders  
From: Bald Eagle
Date: 4 Aug 2022 06:40:00
Message: <web.62eba114f9bd2f341f9dae3025979125@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> 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

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.