Filemapping and Vectors....
Just spent the past week finishing up a generic systems module where I've encapsulated file I/O stuff for a win32 system. The key aspect of the systems module (feature) revolves around the use of filemapping when applicable. It does take up some extra memory (actually quite alot depending on file size), but it is capable of offering some very fine tuned file access capabilities. Not to mention if a virtual file system is implemented later, read and writes can happen quite fast. Of course, filemapping doesn't work everywhere, so there are provisions for a non-filemapped mode.
I started out wanting to create a template class that would store a 2D or 3D vector, but then I sort of settled on them just being of type float. I also decided on writing a TPoint2 and TPoint3 class for storing points in 2D and 3D. The TPoint# classes had point/vertex specific operation tagged onto them. Then there was the big debate on whether I should inherit the TPoint# class to create the TVector# classes. In the end, I ended up just using encapsulation instead of inheritance. On the one hand, inheritance means I wouldn't need to rewrite alot of code to create the TVector# classes, but on the other hand, it would mean that I may have to do some overloading of the methods defined in the parent class. So, in the end, I decided that using encapsulation may be better for the time being. It would be nice to be able to have one pointer pointing to either a vector or vertex based on polymorphism, but I felt that there may be some ambiguity there on my part later on as I begin to abuse that. So, for current purposes of making things clean, cut and dry, I felt that having seperate classes for vector and vertex was a good idea.
Of course, none of this code is tested either, so I'll be field testing them later with my newer and later projects.
-------------------------------
While looking around for the generic rotation matrix for rotating around an arbitrary axis, I ran across the Quaternion vs Vector debate. It was kind of interesting to read about, and I think both sides pose valid arguements. For me, however, at current stages, I still feel that vectors are easier to manipulate, since it is still a much more straight forward mapping to the 3D space we work in. I think I read one person said in his post "why create an extra dimension to make things more complicated when the 3 we have works" or something like that. Of course, there probably are other benefits to quaternion, which I will definitely look into, but as for representation, I somehow still like vectors.

0 Comments:
Post a Comment
<< Home