3D Math Data structures/SIMD

Bill Baxter dnewsgroup at billbaxter.com
Sat Dec 22 02:15:35 PST 2007


Jérôme M. Berger wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Janice Caron wrote:
>> On 12/22/07, Janice Caron <caron800 at googlemail.com> wrote:
>>> It's not obvious to me why the elements should be x, y, z and w. How
>>> does this generalize? What's the rule? Is it "Start at 'x', proceed up
>>> the English alphabet till you get to 'z', then after that work
>>> backwards from 'w' down to 'a'? I don't get it. Seems like an odd and
>>> arbitrary rule, and also totally English-centric. (Well, we wouldn't
>>> want to use the Cyrillic alphabet would we? That's foreign!)
>> I withdraw that last remark. It was uncalled for. I was trying to
>> posit that there is nothing special about the English alphabet, and
>> that all Unicode letters are acceptable as identifier names, but I
>> didn't express that very well, so if I caused any offense, I
>> apologise.
>>
>> I still don't see how the rule generalises to N elements though, and
>> so my question about the rule is still open.
> 
> 	I guess, he meant to say that .x, .y .z and .w could be used as an
> alternative (and in addition) to [] for small vectors. However, the
> problem is that the choice of letters is application-dependent:
>  - 2D vectors often use (u, v) as well as (x, y);
>  - 4D vectors often use "t" for the 4th component instead of "w".
> 
> 	Something that could be nice:
> 
> Vector!(double[3], "abc") vec;
> 
> 	The "abc" string would be optional, but if given it would need to
> be the same size as the vector and it would tell the compiler that
> we want to be able to access the elements with vec.a, vec.b and
> vec.c in addition to vec[i]. This would allow us to specify what
> letters we want to be able to use for any given application.

That's a nice idea.  It would also have the side effect of making things 
like colors ("rgb") and vectors ("xyz") distinct types automatically.

--bb



More information about the Digitalmars-d mailing list