Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually, you sort of prove my point there.

How does someone looking at the code know which parts of projection and model get multiplied here ?

At least make it:

     view.setVector(projection.getMatrix() * model.getVector());
Because '*' applied to a model or a projection could literally mean anything, there might be many elements in those structures that are candidates for multiplication.

By making it explicit what gets multiplied the code is less clear than it could be.

If they're simple arrays without further fields attached to them then you could do:

    view = matvecmul(projection,model);
And that's pretty close to the overloaded example.


The point is that there are fixed rules in Maths for what happens when you multiply 3x3 matrix by a 3x1 matrix and if this is even possible. Those should be enforced by the person writing the library's overloaded features not be left to the programmer to know which is the appropriate function to call.

Multiplying matrices is no more weird than multiplying a float by an int or a positive and negative number.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: