Questions asking us to recommend or find a tool, library开发者_高级运维 or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questioni'm looking for a 3d math library in python or with python bindings.
it needs to handle rotation, translation, perspective projection, everything basically.
what im NOT looking for is a library aimed at drawing on the screen, googling for hours only led to 3d libraries bent on rendering something to the screen. i dont want any visualization whatsoever, all i need is to be able feed a library x,y,z coordinates and recieve the x,y screen coordinates.
i dont mind if its a visualization library, as long as it can be used without rendering anything to the screen.
is there anything like this for python?
Edit: please dont recommend scipy/numpy as they arent aimed at 3d math but at math in general, they look like great tools if i wanted to build the library myself, which i dont. thanks.
OpenCV - Python Interface can handle all the operations you've mentioned.
I hear SciPy's excellent for this as well, but I've only used OpenCV.
transformations.py
A library for calculating 4x4 matrices for translating, rotating, reflecting, scaling, shearing, projecting, orthogonalizing, and superimposing arrays of 3D homogeneous coordinates as well as for converting between rotation matrices, Euler angles, and quaternions. Also includes an Arcball control object and functions to decompose transformation matrices.
Authors: Christoph Gohlke http://www.lfd.uci.edu/~gohlke/ Laboratory for Fluorescence Dynamics, University of California, Irvine
Try gameobjects -- it's a math library that includes Python classes for matrices and vectors, along with methods for transformations. I think it will provide most (if not all) of what you need, plus it's pure Python so you can modify it if you need to.
is SAGE any use to you?
http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/
http://www.sagemath.org/
I'm working on one now. https://github.com/adamlwgriffiths/Pyrr
It uses numpy for speed. The aim is to provide a pure python 3D maths lib.
I'm avoiding external libs because I'm sick of having to follow complex software installs. Python should be easy.
python-math3d is another good 3D mathematic library which is object oriented https://github.com/mortlind/pymath3d
import math3d as m3d
v = m3d.Vector(1,2,3) # A vector object
o = m3d.Orientation.new_euler((1,0,0), "ZYX") # An Orientation object from one type of euler angles
t = m3d.Transform(o, v) # A Transform object created using the vector and orientation
t2 = m3d.Transform()# Another Transform object (Identity)
t2.orient.rotate_x(3) # rotate the transformation around x
res = t * t2 #Matrix multiplication
What about PyGame? I never used it, but it may contain what you're looking for.
I would suggest MayaVi. Please take a look at the given link. It does almost everything you mentioned.
http://cgkit.sourceforge.net/doc/index.html
The implementation isn't always the best, but it includes quaternions as well as the standard matrix and vector types. I've used it for tools on a couple commercial game projects.
精彩评论