3d Math Library For Python [closed]

2020-02-21 04:35发布

问题:


Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 6 years ago.

i'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.

回答1:

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.



回答2:

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.



回答3:

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



回答4:

is SAGE any use to you?
http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/
http://www.sagemath.org/



回答5:

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



回答6:

I would suggest MayaVi. Please take a look at the given link. It does almost everything you mentioned.



回答7:

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.



回答8:

What about PyGame? I never used it, but it may contain what you're looking for.



回答9:

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.