POV-Ray : Newsgroups : povray.general : condition parsed as vector : Re: condition parsed as vector Server Time
8 Aug 2024 06:18:20 EDT (-0400)
  Re: condition parsed as vector  
From: Tor Olav Kristensen
Date: 16 Feb 2001 16:43:48
Message: <3A8D9E92.287058D3@hotmail.com>
KalleK wrote:
> 
> Ok. I killed that strange macro:
> 
>   #macro CompV (V1, V2)
>    ((!(V1.x=V2.x)|!(V1.y=V2.y)|!(V1.z=V2.z))=0)
>   #end
> (It was crazy, I know.)

Hello again Kalle.

Yes, that macro was a bit crazy !

Most people use DeMorgans laws to simplify logic
expressions, but for me it seems like you have 
used it to complicate the expression.

That macro could have been written like this:

#macro CompV(V1, V2)
  (V1.x = V2.x & V1.y = V2.y & V1.z = V2.z)
#end // macro CompV 


But maybe you knew that.


-- 
Best regards,

Tor Olav

mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok


PS.: For those of you that don't know DeMorgans laws 
for boolean expressions, here they are (in POV-style):
(In the following P and Q are boolean variables or expressions.)

(!(P & Q))   is equivalent to   (!P | !Q)
(!(P | Q))   is equivalent to   (!P & !Q)


From this follows that:

(!(!P | !Q))   is equivalent to   (P & Q)
(!(!P & !Q))   is equivalent to   (P | Q)


Here's an example:

"aa is neither 1 nor 4":

(aa != 1 & aa != 4)   is equivalent to   (!(aa = 1 | aa = 4))


And then another one:

"aa is greater than or equal to 1, and less than 4"

((aa >= 1) & (aa < 4))    is equivalent to   (!(aa < 1 | aa >= 4))


Another POV-related aspect of this is that it can be used 
to simplify (or rewrite) expressions with unions, intersections
and inverse statements:

The OR  operator:   |   corresponds to:   union   (or merge)
The AND operator:   &   corresponds to:   intersection
The NOT operator:   !   corresponds to:   inverse


Post a reply to this message

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