|
|||
This is unofficial implementation(java source code) of the
javax.vecmath package specified in the Java(TM) 3D API 1.2 This is Free software, provided AS IS, with NO WARRANTY. Bug reports, comments are welcome. Note that this implementation corresponds to Java3D 1.2 specification. My implementation has full specification implemented and has full source code. Download API 1.2 Java(tm)
C++ portNow supports Visual C++ 6.0 I decide to port this javax.vecmath package to C++ because the parallel C++ version can make a FAST vector/matrix package by the original Java3D specification's unique natures. Java3D designers decided to;
Design decision (1)-(3) are from Java's inherent speed problem. (1) looks like a bad approach in object-orientation and thread-safy sence, but if neccesary, encapsulation can be done by wrapper classes (Java3D does have wrappers for their SceneGraph use). (2) can cause subclassing problems, but since each method does an apparent and natural job, the semantics can be kept consistent. (3) can make a code bloat problem because no for/while loop with array indexing is in the library code. But I found it not so bad after I tried implementation, and it makes this library FAST.(4) was a very good decision. This makes your programs semanticly consistent and increases readabilty. Luckly, these four points makes this parallel C++ library very unique. Highest priority to time efficiency. i.e. no 'virtual' calls, no 'new's, extensively inlined templates, public members, and para-phrazed calculation(no loops and array indexing in methods). For example, not having an array representation in Matrices, the determinant of Matrix3 is coded as; template < class T > T Matrix3 < T >::determinant() const { // I believe this is the fastest way, less calculation and no indexing. return m00*(m11*m22 - m21*m12) - m01*(m10*m22 - m20*m12) + m02*(m10*m21 - m20*m11); } Off cource there are shortcomings in this C++ package.
'operatoer[]' is not supported intensionally, because this can lead to a programming style which can cause a performance problem. // a bad user program Vector3d u(1,2,3), v; Matrix3d m(1,2,3,4,5,6,7,8,9); // this can be very slow for (unsigned i = 0; i < 3; i++) for (unsigned j = 0; j < 3; j++) v[i] = m(i,j)*u[j]; This syntax could be supported in the library, but you should use METHODs. m.transform(u, &v); // much faster or v = m*u; // others like this style better. which are much faster, and readable. A lot of methods are prepared so that users don't have to access elements directly. Other features of the C++ package are;
Download API 1.2 C++ port
Links
|
[Feedback] * Mail to: hiranabe@esm.co.jp |