Standard math classes: some changes and questions

I’ll focus on Quaternion, Vector2f, Vector3f, and Matrix3f.



Null checking should either happen on all functions or none of them. Vector2f.add(v) shouldn’t check to see if v is null if Vector2f.cross(v) doens’t. I’m thinking of putting in no null/bounds checking for any functions. It’s the speediest option and everyone should be able to very quickly see they get a null pointer (if they happen to call the functoin will null) exception so it shouldn’t break anyone’s code.



set() will be the standard function to convert from one to another. For example, Quaternion.fromRotationMatrix(Matrix3f) will become Quaternion.set(Matrix3f).



All functions such as multiply, add, cross, ect ect will have a

A.mult(b) which returns a new ab without modifying A(return ab)

A.mult(b,c) which stores into C the value of AB (c=ab)

A.multLocal(b) which stores into A the value of Ab (A=b)





What do you think?

I do not think that the math class should cheek for null pointers. It takes up time and programs should not pass null pointers.

i agree with removing the null checking.



However, I dont agree with the set(…) method as it doesn’t describe what its doing to be honest. I dont want to go to look at the java docs to see that



Quaternion.set(float, Vector3f); is the same as fromAngleAxis(float, Vector3f);



Thats my opinion anyway and should be taken very light heartedly. Whats the reasoning behind the set(…) methods?



DP

I think the changes make sense. Refactoring at this point seems a bit… wrong, but no big.