POV-Ray : Newsgroups : povray.general : Rounding object : Re: Rounding object Server Time
6 Aug 2024 06:16:43 EDT (-0400)
  Re: Rounding object  
From: Christopher James Huff
Date: 11 Jul 2002 10:32:10
Message: <chrishuff-DDFDF7.09292011072002@netplex.aussie.org>
In article <hfbqiukqi8tefqb6rb0o4sv5esm6eunlvt@4ax.com>,
 W?odzimierz ABX Skiba <abx### [at] babilonorg> wrote:

> You should really spend a little of time checking old posts and not waste own
> time to work with not efficient macros. Considering commented trace is some
> kind of your shortcut for some content you can write your stuff this way:
> 
> #macro IInside(obj,vec)
>   #local w = <1,2,3>;//trace(obj,vec,z); 
>   (w.gray=0)
> #end

Actually, the .gray conversion multiplies each component by a factor 
(because each component has a different contribution to the total gray 
value) and sums up the results. This usually works fine for colors, but 
you have a point which may have negative components, so there are valid 
results that will still give w.gray = 0. It is better to check each 
component individually...but you are right in that the if() statement is 
unnecessary.

#macro IInside(Obj, Vec)
    #local W = <1,2,3>;//trace(obj,vec,z);
    ((W.x = 0) & (W.y = 0) & (W.z = 0))
#end

A shorter and clearer way (assuming you have math.inc included and don't 
care about the macro overhead):

#macro IInside(Obj, Vec)
    #local W = <1,2,3>;//trace(Obj, Vec, z);
    (VZero(W))
#end

BTW, always use at least one upper-case letter in variable names, it 
prevents conflicts with future keywords or standard include stuff. This 
has happened before, I think the Liquid Spray include used "r" as a 
name, which became a reserved keyword in MegaPOV.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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