473,768 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Vector math library

Hi, I'm new to this mailing list and fairly new to Python as well. I'm
working on a prototype for a 3D game using OpenGL, and take this
opportunity to learn Python better.

I'm looking for a good library for vector math. I need to do vector
addition, cross products, dot products etc. and probably in the future
I'll need matrix math as well.

So far I've used the Scientific library, which is very nice, but
unfortunately it crashes when I use the Rotation class under OSX (which
is my current development environment). I've seen mailing list posts
that suggests that this crash is because of some problem with 64 bit CPUs.

I guess I can find a workaround for this problem, but first I want to
check if there's a better library for vector math. When I googled for
vector libraries, I found people claiming that the Numeric library can
be used for vector math. But skimming the Numeric documentation, I
didn't find a cross product function for instance, but it may just that
I don't understand how to use it.

I also found SciPy, but it doesn't seem to have any vector math in it.
In fact, I'm a bit confused about the libraries SciPy, Scientific,
Numeric and NumericArray and the relations between them.

Any suggestions on what library I should use?

Best regards,

Martin Vilcans
http://www.librador.com
Dec 31 '05 #1
5 9999
Bas
I am not a regular user of the libraries that you mention, but I played
around with some of them because I need a replacement for Matlab.

Numeric, NumArray and SciPy should be more or less compatible. All the
functions you mention should be in there, or otherwise should be
trivial to implement. Have a look at the functions cross(), dot(),
inner(), outer(). Addition is just a+b.

As far as I know Numeric was the original vector lib. NumArray was
written as a successor but ended up as a fork due to some speed
concerns. Scipy is the latest and tries to unite the previous two by
implementing the best of both worlds. For future work you should stick
to SciPy. Right now it is probably somewhere in a beta stage, but
expect a final version in half a year or so. Hopefully it ends up being
THE vector lib for python to avoid confusing beginners like you.

Cheers,
Bas

Dec 31 '05 #2
martin,

pyformex has a vector module as well.
its not very pythonic, but it could help you out creating a version of
your own.
worth checking out

Dec 31 '05 #3
Martin Vilcans wrote:
Hi, I'm new to this mailing list and fairly new to Python as well. I'm
working on a prototype for a 3D game using OpenGL, and take this
opportunity to learn Python better.

I'm looking for a good library for vector math. I need to do vector
addition, cross products, dot products etc. and probably in the future
I'll need matrix math as well.


Take a quick look at VPython. Should be great for breadboarding your
display and calculations.
--
-Scott David Daniels
sc***********@a cm.org
Dec 31 '05 #4
And then more!

I started out using cgtypes from the cgkit. Lots of other graphics
goodies in there also:

http://cgkit.sourceforge.net/doc/cgtypes.html

In the end I ended up rolling my own to better understand the whole
thing.

Dec 31 '05 #5
Martin Vilcans wrote:
Hi, I'm new to this mailing list and fairly new to Python as well. I'm
working on a prototype for a 3D game using OpenGL, and take this
opportunity to learn Python better.

I'm looking for a good library for vector math. I need to do vector
addition, cross products, dot products etc. and probably in the future
I'll need matrix math as well.


ZOE has an la a module that helps with linear algebra computations
including (three-dimensional) vectors and matrices:

http://www.alcyone.com/software/zoe/

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
You are the lovers rock / The rock that I cling to
-- Sade
Dec 31 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3207
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII "stereolithography" file (*.STL) into my program. This has the following syntax... Begin STL Snippet **********
19
3303
by: Carlo Milanesi | last post by:
Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector<double> v1(3), v2(3); v1 + v2; // Illegal v1 * 2.; // Illegal In addition, vectors of different dimensions belong two different spaces (types). But in C++, the following code is legal:
8
48043
by: Stefan Burger | last post by:
Those of you who are in need for drawing vector lines might be interested in the following code. DrawLine( x1, y1, x2, y2, color ) draws a vector line from any Point x1,y1 to any Point x2,y2 in any color (string format #RRGGBB) by using div-tags. regards Stefan ###############code starts here#########################
1
6055
by: Bernhard Hidding | last post by:
Hello, I'm a beginner in c++ and I would like to implement some math operations into my program. Explicitly, would like to perform cross product calculations. Is there some library or predefined function that is capable to do this or do I have to write a function that can calculate vector products for myself? Furthermore, what data structure should I use? Thanks in advance, Bernhard Hidding
14
4001
by: Michael Sgier | last post by:
Hello If someone could explain the code below to me would be great. // return angle between two vectors const float inline Angle(const CVector& normal) const { return acosf(*this % normal); } // reflect this vector off surface with normal vector
8
2923
by: Sensei | last post by:
I have a quick question about the math library included in the standard C90 (and 99). The gcc, xlc and possibly other compilers/linkers on some unix platforms cannot use any math functions in math.h if a switch (-lm) is used, so *explicitly* having the linker use a file called libm.so or libm.a/dylib/whatever. Is it true on all the platforms? (answer: probably no)
110
8600
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm almost halfway through writing the over 200 functions needed to implement C99's version of math.h, and I would like to have some feedback and/or expert advice on my implementations. Sincerely, Gregory Pietsch
5
10355
by: =?iso-8859-1?B?TWF0dGlhcyBCcuRuZHN0cvZt?= | last post by:
Hello! I'm trying to find what package I should use if I want to: 1. Create 3d vectors. 2. Normalize those vectors. 3. Create a 3x3 rotation matrix from a unit 3-d vector and an angle in radians. 4. Perform matrix multiplication.
3
5804
by: Francogrex | last post by:
Hello, I am new to C++, have some knowledge of programming in splus(statistics). I am trying to append values output by a loop (code below) into a vector (by appending value), that I can eventually export to a text file. The only way I could do this is output one value at a time which doesn't seem elegant because the vector named "input" is not stored in the workspace. How can I have a vector that is saved in the workspace and that I can...
0
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10017
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9843
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5283
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.