First and foremost: the vast majority of the framework has got much faster. Some notable highlights (speed comparisons are approximate and may depend on your computer):
Matrix.Rotationin 3D is 50 times (yes, fifty, as in 5000%) faster than in 0.1.0. As a result,
Vector#rotateis about 60 times faster, and
Plane#rotateare 20 to 30 times faster. 0.1.0 was using some mighty stupid routines to work out rotation matrices; the new implementation uses a quick closed-form algorithm.
- Reflection in planes is now around 10 times faster for vectors, lines and planes.
- Matrix equality testing is now 20 times faster and multiplication is 6 times faster (based on 3x3 matrices). Trace calculation is 100 times faster.
- Many other routines are between 2 and 6 times faster than before.
One change that really helped to speed the whole thing up was removing
value-checking from the vector and matrix
setElements methods. If you pass
non-numeric values to the vector and matrix constructors, you will not get
null any more, but you’ll find that method calls on the objects you get back
probably break. Why you’d be using non-numeric values I don’t know, but you
might find it useful, maybe for doing searches.
There are a couple of new methods:
Vector#eachcan be used to iterate over the elements of a vector.
Plane#isPerpendicularTocan be used to test whether two planes are at right angles to each other. I’ve not implemented this for lines, as skew lines make the definition of ‘at right angles’ a little fuzzy.
A bug has been fixed:
Matrix#augment was chopping columns off due to some
row/column indexes being writted the wrong way round.
And finally, 0.1.0 has some ambiguity regarding use of vectors versus plain arrays. In 0.1.1, any method that takes a vector as an argument will also accept an array. There are situations when you’ll get faster code by taking advantage of this. Methods that take matrices as arguments also accept plain arrays but you need to be careful with this feature. I’ll be writing more about use of arrays shortly.
Go and download Sylvester and let me know how you get on.