The Vector conundrum

Started by
1 comment, last by alnite 12 years, 9 months ago
Hi,

edit: I thought the "subtitle" would be more prominently displayed. I guess I should also mention in the post that this is mainly about C++.

so this is a problem that comes up almost every time I start a project. I'm always unsure what Vector type (in the mathematical sense) I should use. Usually when you use additional libraries you end up with competing Vector datatypes... Box2D, SFML etc. all define their own and if you want to build additional components that are more general purpose (say a path finding mesh) you also want to use a vector type that preferably doesn't depend on an "unrelated" library (I don't want include SFML into every project just for the Vector type). So I lately just decided to use Eigen wherever possible to get some consistency. In the past I often used a self written version or even just plain arrays.

Somewhat similar issues also arise with other things like some libraries having their own string classes and such, this is just the one I run into the most.

How do you deal with this?
Advertisement
Hopefully all the competing vector types are the same size, and you can just pointer-cast between them when passing data between your own 'internal' vector type, and different libraries' interfaces.
I would use your own internal format (arrays, a class, whatever), and provide converters to different libraries' vector classes. That way you can uniformly use your own format for your classes, then when necessary, convert it to another.

This topic is closed to new replies.

Advertisement