Jump to content
  • Advertisement
Sign in to follow this  
Xetrov

C++ - Python 3D Vectors

This topic is 5061 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

I have a nice C++ class for vector math functions which wraps a float[3] -- CVector, and the same thing with Quaternions etc... I'm using boost::python to expose my C++ classes/functions to python. Currently I have wrapped any functions taking or returning a CVector to take or return a boost tuple instead. However this is a somewhat dirty solution as I want to use vector math in python too. So the question is, which would be faster? : 1) Expose the C++ CVector class to python -- pro: easy. con: maybe not too efficient to have to convert all the time -- there might be a lot of vector math... 2) Create a python vector class and convert to that instead of tuples (as I currently am). pro: wont need to make repeated conversions back to C++ vectors. con: the conversion on passing/returning may take a bit longer, also python math functions probably add a little overhead on C++. After writing that out, I think #2 is probably better...

Share this post


Link to post
Share on other sites
Advertisement
I'd also suggest looking into Numeric or Numarray's array class. It's got a well accelerated numerical arrays for doing vector math, plus it does have an api that simplifies reading an array into and out of python. Of course, I haven't really used numeric so I'm not really sure of the performance, but I've heard good things. With well designed use of its api, it can rival c code, b/c thats what it ultimately is.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!