POV-Ray : Newsgroups : povray.general : a really dumb mistake Server Time: 22 Oct 2017 21:06:01 GMT
  a really dumb mistake (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: a really dumb mistake
Date: 25 Aug 2017 19:10:00
Message: <web.59a07598d9dfcaaec437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> In the 16th century, the Inquisition would have burned Clipka at the stake, as a
> warning to other such Necromancers :-P

21st.   Other than that, you're probably right.
Orwell just had the date wrong.

https://campus.aynrand.org/works/1943/01/01/the-soul-of-an-individualist/page1

https://duanegraham.files.wordpress.com/2012/07/s-e-cupp-rand-quote.jpg


Post a reply to this message

From: Bald Eagle
Subject: Re: a really dumb mistake
Date: 11 Sep 2017 14:40:01
Message: <web.59b69f36d9dfcaaec437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Challenge accepted ;)
>
> #declare MY_VALUE = 10;
> #for(C,1,19)
>   #debug concat("\n","My Value = ",str(MY_VALUE,1,0),"\n")
>   #declare MY_VALUE = 43-MY_VALUE;
> #end

So, I looked further into this, since it was so elegant,
and I came across this discussion, and further suggested improvement:


from:
https://stackoverflow.com/questions/18941019/simplest-way-to-toggle-a-integer-variable-between-two-values
( ^= operator is the XOR operator)


"Another way is to toggle an index between 0 and 1 and index an array with that:

int main() {
    int const values[] = {0x55, 0xaa};
    int selector = 0;

    selector ^= 1;                // toggle index
    int value = values[selector]; // select value
}

This is also future-resistant. If in the future OP wants to round-robin between
3, 4, or N values, just add to the array and change selector ^= 1 to selector =
(selector+1)%N."

------

I'm unfamiliar with the bitwise operators in POV-Ray, so interpreting the docs
is a bit unclear to me.
"bitwise_xor(A,B,...)
Bitwise XOR of two or more float values considered as integers."

This would make a sweet little macro for people to use in lots of future scene
files - so good, it should be in one of the standard include files.

I might try to code it up tonight, unless someone beats me to it   ;)


Post a reply to this message

From: Bald Eagle
Subject: Re: a really dumb mistake
Date: 11 Sep 2017 17:50:05
Message: <web.59b6cc01d9dfcaaec437ac910@news.povray.org>
> I might try to code it up tonight, unless someone beats me to it   ;)

or over lunch  :D

Like so:

#macro CycleValues (_Array, _Counter)
 // Round-robin cycle through N values
 // Bill Walker September 2017
 #local N = dimension_size (_Array, 1);
 #local selector = mod (_Counter, N);
 // selector will range from 0 to N-1
 // Return the value in _Array corresponding to _Counter
 _Array [selector]
#end // end macro CycleValues


#declare RoundRobin = array [4] {2, 5, 9, 13};
#for (i, 0, 10)
 #declare Value = CycleValues (RoundRobin, i);
 #debug concat ("Array value for i=", str(i, 2, 0), " is ", str(Value, 3, 0),
"\n")
#end // end for i


Post a reply to this message

From: clipka
Subject: Re: a really dumb mistake
Date: 11 Sep 2017 21:18:00
Message: <59b6fd88$1@news.povray.org>
Am 11.09.2017 um 19:46 schrieb Bald Eagle:
> 
>> I might try to code it up tonight, unless someone beats me to it   ;)
> 
> or over lunch  :D
> 
> Like so:
> 
> #macro CycleValues (_Array, _Counter)
>  // Round-robin cycle through N values
>  // Bill Walker September 2017
>  #local N = dimension_size (_Array, 1);
>  #local selector = mod (_Counter, N);
>  // selector will range from 0 to N-1
>  // Return the value in _Array corresponding to _Counter
>  _Array [selector]
> #end // end macro CycleValues
> 
> 
> #declare RoundRobin = array [4] {2, 5, 9, 13};
> #for (i, 0, 10)
>  #declare Value = CycleValues (RoundRobin, i);
>  #debug concat ("Array value for i=", str(i, 2, 0), " is ", str(Value, 3, 0),
> "\n")
> #end // end for i

Invoking a macro in a loop? Can't imagine this to be of any use in terms
of efficiency ;)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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