I wonder how performance compares to the vector math library in closure (goog.vec)?

### Seth Ladd

Shared publicly -The Dart Vector Math library gets a new version, thanks to library author +John McCutchan

From the post:

The Dart Vector Math Library is for game or WebGL programmers needing 3D vector math in Dart.

ChangeLog:

Serialization between Float32Array and Vectors/Matrices

Added many self* methods to matrix and vector classes:

selfAdd

selfSub

selfMultiply

etc...

The self* methods avoid allocating new instances- reducing immediate overhead and, later, garbage collection overhead. Because of the avoided work they are faster than overloaded operators. Please use them whenever possible.

Matrix inversion

2x2,3x3,4x4

Upper 3x3 of 4x4 (rotation submatrix)

Matrix rotation constructors

Matrix adjoint

Many bugs fixed

Specialized branchless constructors

Updated to support the latest version of Dart

From the post:

The Dart Vector Math Library is for game or WebGL programmers needing 3D vector math in Dart.

ChangeLog:

Serialization between Float32Array and Vectors/Matrices

Added many self* methods to matrix and vector classes:

selfAdd

selfSub

selfMultiply

etc...

The self* methods avoid allocating new instances- reducing immediate overhead and, later, garbage collection overhead. Because of the avoided work they are faster than overloaded operators. Please use them whenever possible.

Matrix inversion

2x2,3x3,4x4

Upper 3x3 of 4x4 (rotation submatrix)

Matrix rotation constructors

Matrix adjoint

Many bugs fixed

Specialized branchless constructors

Updated to support the latest version of Dart

The Dart Vector Math Library is for game or WebGL programmers needing 3D vector math in Dart. ChangeLog: Serialization between Float32Array and Vectors/Matrices; Added many self* methods to matrix and...

9

6

8 comments

+Evan Parker I plan on writing a benchmark- my question is what operations are most important? basic operations, 4x4 matrix multiply, dot product, cross product come to mind. I have some bandwidth coming up so I'm taking suggestions.

Others that come to mind: matrix inverse, computing rotation matrices, applying a rotation to an existing matrix, matrix vector product

+Evan Parker I have published some initial benchmarks to the Dart mailing list- https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/3af606bb094819ce . I compare DartVectorMath, glMatrix.dart, and a new feature I've been working on for DartVM- Float32List SIMD (SSE) operations.

Cool, thanks +John McCutchan. Have you had a chance to compare goog.vec as well yet?

+Evan Parker Is there a port of goog.vec to Dart?

I've taken a look at mat4.js from goog.vec and the code for matrix multiply is the same as every other 4x4 matrix multiply: cache values in local variables, do the dot products and then store them back. goog.vec will take any array like object (Float32Array,Float64Array,Array), so the performance of goog.vec will depend on which of those are used. Currently, the performance of indexing into Float32/64Array under DartVM is quite bad, so it would be best to avoid it.

Not that I know of. It would have to be a Javascript-to-Dart comparison.

Add a comment...