bearophile wrote:
ponce:
Vibrant has been open source'd (again):
http://bitbucket.org/ponce/vibrant
Very good. I have seen 2D vectors implemented something like ten times in D
code, so I think it's time to stop this. They need to go in the standard
library:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/vec2.d
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/vec3.d
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/vec4.d
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/vectorop.d
Definitely we need vectors in Phobos.
Useful math, fast too:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/common.d
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/rounding.d
Actually, I don't see any functions which are faster than std.math.
std.math.exp2() is *much* faster than common.pow2() (one slow
instruction, vs five!!!) And exp2 sets the flags correctly.
expi() is faster than sincos().
Half floats, I don't know if they are better than user defined floats of
Phobos2:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/half.d
Quaternions:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/quat.d
A color module is useful:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/misc/colors.d
Python std lib has colorsys:
http://docs.python.org/library/colorsys.html
More useful general matrix code:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/mat4.d
Some very basic geometry code fit for a std.geometry module:
http://bitbucket.org/ponce/vibrant/src/tip/trunk/common2/math/math2d.d
I think all those things (maybe with a little more docs, improvements,
unittests, contracts) are fit to be added to Phobos, because:
- they are basic things that are commonly useful;
- they aren't a lot of code;
- they will be useful ten years from now too, they will not become obsolete;
- I have seen them implemented in user D code several times;
- Some of them are present in my dlibs1 and I have used them several times.
I agree. There's some useful stuff here.