dawg at dawgfoto.de
Sat Feb 4 16:17:01 PST 2012
> First criticism I expect is for many to insist on a class-style vector
> library, which I personally think has no place as a low level, portable
> Everyone has a different idea of what the perfect vector lib should look
> like, and it tends to change significantly with respect to its
- Thing like toDouble, toFloat don't map to vectors if they change the
number of elements.
- What's getX(byte16), swizzling makes sense for float4/double2, not sure
about the rest.
- Using named free functions for operands (or, complement, neg) is overly
So indeed my proposal is to prefer GLSL-like syntax.
// construction conversion
auto f = float4(1.0, 2.0f, 3, 4);
auto f2 = v.yxzw; // using opDispatch
auto d = double2(v.wy);
auto d = double2(v.get!(0), v.get!(1)); // probably someone knows a
trick for compile time indexing (v)
auto f3 = float4(1.0, d, 2);
double d = f3.z;
// a lot of operands can be mapped and are already
f |= f2;
f = f & ~f2;
// named functions for the rest
auto f1 = float4.loadAligned(p);
auto f2 = float4.loadUnaligned(p);
auto f3 = float4.broadcast(1.0f);
> I feel this flat API is easier to implement, maintain, and understand,
> I expect the most common use of this lib will be in the back end of
> own vector/matrix/linear algebra libs that suit their apps.
Phobos should provide at least basic vector and matrix implementations.
More information about the Digitalmars-d