markrogoyski / math-php

Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
MIT License
2.35k stars 241 forks source link

Add vector, matrix and quaternion operations for 3d geometry #437

Open bbesseling opened 3 years ago

bbesseling commented 3 years ago

The library could more easily support common 3d geometry operations as e.g. used in cad and games. Vector: If we could add left/right-handed cross product? If we could slerp and interpolate using a function? Matrix: If we could factory scale, rotation and translation 2x2, 3x3 and 4x4 (+w) matrices and maybe their inverses? Quaternion: If we could factory from axis+angle, euler or at+up vectors? If we could slerp, nlerp and interpolate using a function? It is also very useful in 3d to have a Transform type that keeps scale, translation and rotation as separate vectors and a quaternion. This eliminates many matrix inversions e.g. when animating boned 3d meshes. Stretch goal nice to have a Project type that can do perspective and isometric projections. from 3d to 2d for rendering. Since these operations are all very simple, is it better for me to write the code and for someone then to validate the code, or is it easier for somebody who already understands the code to add these? I'd be happy to provide C++ sample code.

markrogoyski commented 3 years ago

Hi @bbesseling,

Thank you for your interest in MathPHP.

If you have ideas or requests for specific new math functions, can you provide some concrete examples of how you expect them to work. For example, a function called XYZ that takes an input 2x2 matrix with values (...) and produces as output a 2x2 matrix with values (...). Also, if there is any external documentation (could be Wikipedia or anything) on the function provide that as well so we can make sure we understand your request. And finally, if the functionality you are requesting exists in any other libraries, providing a reference to that is also useful to get ideas from.

And of course, the quickest way would be to provide code yourself in the form of a pull request.

Thanks, Mark