• Advertisement
Sign in to follow this  

The Vector conundrum

This topic is 2399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement