Need help with generic vector math
I'm trying to create a Vector type with generic math approach.
So I get a error at the test code, how can I do this right?
5 Replies
you have to do
var x = a.Dot<Vec2<float>, float>(a);
C# isn't able to use generic constraints to do inference, so it doesn't see TVec : IVector<TVec, TScalar>
when trying to figure out what TScalar isI see the problem, but this isn't convenient at all?
Is there any I can change to make such extension work, and write as less repeatative codes as possible?
Is there any I can change to make such extension workno, not that i know of besides just redefining the extension methods for every concrete IVector implementation
That sounds pretty sad.
The return type of Dot is a generic type and you haven’t specified a type anywhere. (Btw I think the solution is probably using fewer generics not more, there’s a lot going on there.)