|
|
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
|
|
|
|
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
|
|