Low dimensional matrices, vectors, quaternions and a cubic equation

#ponce spam at spam.spam
Tue Apr 20 03:35:19 PDT 2010


> For the record: at least for cross(), I prefer the latter version. It always seemed awkward to me to make a symmetric (ok, anti-symmetric in this case) operation like this a member, because vec1.cross(vec2) doesn't look symmetric at all anymore. Furthermore, in the absence of an actual operator for the cross product (which we can't have, unless we resort to overloading abuse), the latter is closer to mathematical notation.
> 
> -- Clemens

I also prefer the second version. 
Don't we like to write max(a, b) and not a.max(b) ?

Ideally I'd like to be able to write operation(x) or operation(x, y) indifferently with x and y being a scalar or a small vector type, like in shader languages. 

I tried with min/max but failed due to ambiguous overloading:

T min(T)(T a, T b)

vs

vec2!(T) min(T)(vec2!(T) a, vec2!(T) b)

and finally changed names (min, min2, min3...) to overcome this.


D has modules, overload sets, specialization etc... so maybe someone more skilled can figure how to sort it out.





More information about the Digitalmars-d mailing list