Python, geometry and visualisation - python

I'm looking for a Python library that would allow me to visualise geometrical data. Nothing extremely complicated, just a bunch of points in the plane or space and a few basic shapes that I would generate.
I had a look at this question and the answers to it, but the focus over there seems to be on computation.

How about Matplotlib/mplot3D?

Related

How to draw shapes at non-integer locations in Python OpenCV? [duplicate]

I am plotting some geometry on an image. The problem is the coordinates are coming out as floats, so I am not able to plot them. As a work around I am using floor(); to truncate it to nearest Integer. This works fine in some cases, except that it shifts my image a little bit.
x=9.7
x'=floor(x)= 9 //the plot is now at 9 and not at 9.7 as desired, (this is 'shift')
But in cases where my requirement is to draw multiple shapes at equal distance I am facing problem as the shift (because of floor();)is not uniform for each shape.
It is just like quantization noise in digital communication.
Is there any way I can get around this problem ?
This problem is actually quite a common one in computer graphics. Rasterisation is the problem domain you are currently struggling with. You may find Bresenham's line algorithm a good introduction to the topic. Here is a nice interactive site with a few different rasterisation algorithms.
Hope that helps!

Generating 3D (x,y,z) Point Clouds from Two 2D Stereo Images

I've been trying to read through the Stackoverflow questions for generating point clouds (x,y,z) coordinates from a left and right stereo image pair.
I haven't come to any definite solution, and I'm asking the community here for some help.
Problem statement: Given two stereo images, generate 3D (x,y,z) cartesian coordinate point clouds from those and do so in a way that lends itself to completing this point-cloud generation in a way that could work over a large set (thousands) of pairs of stereo images
My programming language experience lends itself to MATLAB, but I've dabbled in Python, and C++ is limited, but I may be able to work in that as well.
Speed is a factor here, so the the idea is to find a quick method of successively going through these pairs and generating the point cloud.
NOTE: I am not asking for the BEST as to avoid comparative solutions, I'm just asking for solutions.
Thank you very much!
Edit: After being recommended to utilize the Stereo Block Matching implementation in OpenCV, I may steer away from this method, as there is a wide variation in regards to texture of the topographical pictures that I'm dealing with.
What you probably want is called "Stereo Block Matching". If you don't feel like writing it yourself, OpenCV has an implementation ready to go (even a CUDA accelerated version).

Python graph like windirstat?

I'm interested in using python to make diagrams representing the size of values based on the size of squares (and optionally their colour). Basically I'm looking for a way to make overviews of a bunch of values like the good old program windirstat does with hard-drive usage (it basically makes a big square representing your harddrive and then smaller squares making up the area inside of it representing different programs, the bigger the square the larger the file, colour indicates the type of file). I'm fairly familiar with matplotlib, and I don't think it's possible to do something like this with it. Is there any other python package that would help? Any suggestions for something more low level if it's not? I guess I could do it manually if I could find a way to draw the boxes programatically (I don't really care about the format, but the option to export SVG as well as PNG would be nice).
Ultimately, it would be nice to have it be interactive like windirstat is, where if you were to hover over a particular square you get more information on it, and if you clicked on it maybe you'd go in and see the makeup of that particular square. I'm only familiar with wxpython for GUI stuff, not sure if it could be used for something like this. For now I'd be happy with just outputting them though.
Thanks a lot!
Alex
Edit:
Thanks guys, both your answers helped a lot.
You're looking for Treemapping algorithms. Once implemented, you can transform the output (which should be rectangles) into plotting commands to anything that can draw layered rectangles.
Edit:
More links and information:
If you don't mind reading papers, the browser-based d3 library provides for 'squarified' treemaps (js implementation). They reference this paper by Bruls, Huizing, and van Wijk. (This is also citation 3 on the wikipedia article)
I'd search on the algorithms listed on the linked Wikipedia article. For instance, they also link to this article, which describes an algorithm for "mixed treemaps". The paper also includes some interesting portions at the end describing transformations into other-than-rectangular shapes.
Squarified certainly appears to be the most common variety around. The above links should give you enough to work towards a solution or, even, directly port the d3 implementation. However, the cost of grokking d3's model (which is something like a declarative form of jQuery) may be somewhat high. At first glance, though, the implementation appears relatively straightforward.
Squaremap does this. I haven't used it (I only know it from RunSnakeRun) and its documentation is severely lacking, but it seems to work.

3D Transformations in Python [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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 question
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.
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.

3d Math Library For Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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 question
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.
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.

Categories