|
|
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> Hi Ricky
>
> It took me a while to figure out what is going on there.
> You are exploiting the automatic vector promoting "feature".
Well, that's what I was implying, and it seemed like you "knew" about that
already.
> > > I don't think that it is possible to investigate the number of components in a
vector without it being promoted a
utomatically ...
I know that clipka gave me an example that stuck, of which I use variants all
the time:
http://news.povray.org/povray.documentation.inbuilt/message/%3Cweb.59398df47cb8f4dcc437ac910%40news.povray.org%3E/#%3Cw
eb.59398df47cb8f4dcc437ac910%40news.povray.org%3E
> Here's my take on it:
>
>
> #macro VectorDimTest(v0)
>
> #local vZ3D = <0, 0, 0>;
> #local vZ4D = <0, 0, 0, 0>;
> #local vZ5D = <0, 0, 0, 0, 0>;
> #local v1 = v0 + 1;
> #local v2 = v0 + 2;
> #local D2 = ((vZ3D + v1).z = (vZ3D + v2).z);
> #local D3 = ((vZ4D + v1).t = (vZ4D + v2).t);
> #local D4 = ((vZ5D + v1).transmit = (vZ5D + v2).transmit);
>
> #if (D2)
> #debug "2D"
> #else
> #if (D3)
> #debug "3D"
> #else
> #if (D4)
> #debug "4D"
> #else
> #debug "5D or scalar"
> #end // if
> #end // if
> #end // if
>
> #end // VectorDimTest
Both of your macros are pretty nice :)
It's early and I'm still on First Coffee, but I'm fuzzily thinking that maybe
there's a way to disambiguate a 5D vector and a scalar by adding and/or
multiplying with vectors containing different signs and testing the result?
My brain is also giving me the impression that binary math and things like (I
said _like_) bitmasks and xor might offer inspiration for a solution.
Post a reply to this message
|
|