|
![](/i/fill.gif) |
> Is it possible to do a Bitwise AND in SDL?
Yes, but not directly. Also note, that, as Warp pointed out, pov numbers
are floating point, so you might lose some bits if you use too many.
Untested suggestion:
// to extract bit K of N:
#macro Bit(K,N)
((floor(N/pow(2,K))) mod 2)
#end
// bitwise operations with K bits
#macro Not(N,K)
pow(2,K)-1-N
#end
#macro Nand(N,M,K)
#local I=0;
#local R=0;
#while (I<K)
#local R = R+(1-Bit(I,N)*Bit(I,M))*pow(2,I);
#local I = I+1;
#end
(R)
#end
#macro And(N,M,K)
Not(Nand(N,M,K),K)
#end
#macro Or(N,M,K)
Nand(Not(N,K),Not(M,K),K)
#end
#macro Xor(N,M,K)
And(Or(N,M,K),Nand(N,M,K),K)
#end
--
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}// Mark Weyer
Post a reply to this message
|
![](/i/fill.gif) |