POV-Ray : Newsgroups : povray.text.scene-files : hf_normal_at macro Server Time
1 Nov 2024 11:15:45 EDT (-0400)
  hf_normal_at macro (Message 1 to 2 of 2)  
From: Christoph Hormann
Subject: hf_normal_at macro
Date: 13 Jun 2000 11:18:04
Message: <394650AD.B02457B1@gmx.de>
This is the code for the hf_normal_at (refer to thread in p.b.i)

It is called like the hf_height_at function, the additional c-parameter
specifies the scale, at which the normal is calculated.  You should keep
it above the HF's resolution and can increase it to have a smoothing
effect.  

As Bob Hughes wrote in p.b.i. the trace function already does this job
and is probably faster and more flexible.  ntl, I decided to post this
for studying purposes.  

// ---------- begin pov-code -----------

#macro hf_normal_at(X, Y, HF, c)

  #local swap=false;

  #local hx = hf_height_at(X, Y, HF);
  #if ((X+c)<1)
    #local h1 = hf_height_at(X+c, Y, HF);
    #local v1 = < c, h1-hx, 0>;
  #else
    #local h1 = hf_height_at(X-c, Y, HF);
    #local v1 = <-c, h1-hx, 0>;
    #if (swap=true)
       #declare swap=false;
    #else
       #declare swap=true;
    #end
  #end
  #if ((Y+c)<1)
    #local h2 = hf_height_at(X, Y+c, HF);
    #local v2 = <0, h2-hx,  c>;
  #else
    #local h2 = hf_height_at(X, Y-c, HF);
    #local v2 = <0, h2-hx, -c>;
    #if (swap=true)
       #declare swap=false;
    #else
       #declare swap=true;
    #end
  #end


  #if (swap=true)
    (vnormalize(vcross(v1, v2)))
  #else
    (vnormalize(vcross(v2, v1)))
  #end

#end

// ---------- end pov-code -----------

--
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Warp
Subject: Re: hf_normal_at macro
Date: 13 Jun 2000 11:40:45
Message: <394655fd@news.povray.org>
Wouldn't it be easier to use the trace() function?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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