3d Math Library For Python [closed]

2020-02-21 04:47发布

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.

标签: python math 3d
9条回答
啃猪蹄的小仙女
2楼-- · 2020-02-21 04:52

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

查看更多
时光不老,我们不散
3楼-- · 2020-02-21 04:54

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.

查看更多
Ridiculous、
4楼-- · 2020-02-21 04:55

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.

查看更多
啃猪蹄的小仙女
6楼-- · 2020-02-21 04:58

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.

查看更多
▲ chillily
7楼-- · 2020-02-21 05:04

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

查看更多
登录 后发表回答