Popular Python recipes tagged "3d"http://code.activestate.com/recipes/langs/python/tags/3d/2015-04-29T07:09:33-07:00ActiveState Code RecipesLecture 1: Applications of Python in Bioinformatics: Visualizing Protein (Python) 2015-04-29T07:09:33-07:00Devashish Dashttp://code.activestate.com/recipes/users/4192116/http://code.activestate.com/recipes/579050-lecture-1-applications-of-python-in-bioinformatics/ <p style="color: grey"> Python recipe 579050 by <a href="/recipes/users/4192116/">Devashish Das</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/bioinformatics/">bioinformatics</a>, <a href="/recipes/tags/plots/">plots</a>, <a href="/recipes/tags/protein/">protein</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This code reads 1qlz.pdb protein file can be downloaded from <a href="http://www.rcsb.org/pdb/files/1QLZ.pdb" rel="nofollow">http://www.rcsb.org/pdb/files/1QLZ.pdb</a> and plots a 3D graph using maplotlib library. For mystery write to me: <a href="mailto:devashish.das@educept.com">devashish.das@educept.com</a></p> <pre class="prettyprint"><code>__author__ = Devashish Das __contact__ = +91-9964218681 __email__ = <a href="mailto:deavshish.das@educept.com">deavshish.das@educept.com</a> __website__ = <a href="http://www.educept.com">http://www.educept.com</a> </code></pre> 3D polygon area (Python) 2012-10-01T16:29:26-07:00Jamie Bullhttp://code.activestate.com/recipes/users/4183059/http://code.activestate.com/recipes/578276-3d-polygon-area/ <p style="color: grey"> Python recipe 578276 by <a href="/recipes/users/4183059/">Jamie Bull</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/area/">area</a>, <a href="/recipes/tags/geometry/">geometry</a>, <a href="/recipes/tags/polygon/">polygon</a>). </p> <p>Function for finding the area of a polygon in a 3D co-ordinate system.</p> STL Writer (Python) 2012-08-22T18:46:34-07:00Manfred Moitzihttp://code.activestate.com/recipes/users/4183316/http://code.activestate.com/recipes/578246-stl-writer/ <p style="color: grey"> Python recipe 578246 by <a href="/recipes/users/4183316/">Manfred Moitzi</a> (<a href="/recipes/tags/3d/">3d</a>). </p> <p>Export 3D objects, build of faces with 3 or 4 vertices, as ASCII or Binary STL (Standard Triangulation Language) file.</p> OpenKinect Mouse Control Using Python (Python) 2012-04-15T18:49:00-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578104-openkinect-mouse-control-using-python/ <p style="color: grey"> Python recipe 578104 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/hand_tracking/">hand_tracking</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/openkinect/">openkinect</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tracking/">tracking</a>, <a href="/recipes/tags/vision/">vision</a>). Revision 2. </p> <p>This is a simple code that lets a user control the mouse and left-click using the Microsoft Kinect, Python, and OpenKinect. </p> <pre class="prettyprint"><code>Computer Prerequisites: -OpenKinect -Python Wrapper for OpenKinect -A Linux machine using Ubuntu -OpenCV 2.1 -OpenCV 2.3 -Python 2.7.2 -A Microsoft Kinect -A Microsoft Kinect USB Adapter -PyGame -Xlib for Python </code></pre> <p>To run this code you either need to start it in the terminal or you need to write a short bash script that runs the code. This is necessary because it requires super-user privileges.</p> <p>The Bash script is (Assuming the code is saved by the name 'Hand Tracking.py' in /home/$USER directory:</p> <pre class="prettyprint"><code>#!bin/bash cd 'home/$USER' gksudo python 'Hand Tracking.py' </code></pre> <p>The code is heavily commented and most of what you will need to know is there. </p> Libreenect (OpenKinect) Minimum Value Joystick With Display - Kinect Demo Using OpenKinect SDK (Python) 2012-03-18T18:52:42-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578080-libreenect-openkinect-minimum-value-joystick-with-/ <p style="color: grey"> Python recipe 578080 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/joystick/">joystick</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/libfreenect/">libfreenect</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/programming/">programming</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/virtual_joystick/">virtual_joystick</a>). Revision 3. </p> <p>This demo requires you to be using a Linux machine and to have libfreenect installed with the python wrapper. This demo also requires you to have opencv, numpy, and pygame. They can all be installed using sudo apt-get install {PROGRAM NAME HERE}. Here are instructions on installing libfreenect: <a href="http://openkinect.org/wiki/Getting_Started" rel="nofollow">http://openkinect.org/wiki/Getting_Started</a>. Okay, so what this demo does is finds the minimum point on the depth image and uses the index of this minimum point to create a four button joystick that codes for 'A', 'B', 'X', 'Y'. It also uses the minimum point and the RGB image to put a circle on the minimum point on the screen. So basically a dot will follow your hand on the RGB image. If the minimum value is larger than 600 (arbitrary units), the color of the dot will change from red to purple and the dot will remain stationary. Also, if the Kinect is not properly opened the first time, unplug it and plug it back in and run in the terminal sudo freenect-glview. After try running the program again. One more thing, this code requires super user privileges so run it through the terminal. Here is how to do this for linux n00bs.</p> <ol> <li>Change your directory the the directory the code is in (use cd {PATH})</li> <li>Run the code using sudo python {FILENAME}</li> <li>Don't forget to add the the .py at the end</li> </ol> wxPython: Dramatic, shaded 3-D buttons that look like round glass in a metal ring. (Python) 2011-11-19T17:37:07-08:00Edward Sitarskihttp://code.activestate.com/recipes/users/4180006/http://code.activestate.com/recipes/577951-wxpython-dramatic-shaded-3-d-buttons-that-look-lik/ <p style="color: grey"> Python recipe 577951 by <a href="/recipes/users/4180006/">Edward Sitarski</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/button/">button</a>, <a href="/recipes/tags/round/">round</a>, <a href="/recipes/tags/wxpython/">wxpython</a>). </p> <p>These buttons work like regular wx buttons and can be used the same way.</p> <p>They are very dramatic and add a strong visual and artistic flair to your interface. Use when there is something really significant and a regular button just doesn't cut it.</p> <p>The buttons are drawn with gradient shading (no bitmaps). They can be any size and support any font.</p> <p>This source has a self-test. Just run "python roundbutton.py".</p> 2D slice of 4D Mandelbrot Fractal and Map it in 3D (Python) 2011-05-26T10:57:39-07:00Derek Harrisonhttp://code.activestate.com/recipes/users/4178123/http://code.activestate.com/recipes/577723-2d-slice-of-4d-mandelbrot-fractal-and-map-it-in-3d/ <p style="color: grey"> Python recipe 577723 by <a href="/recipes/users/4178123/">Derek Harrison</a> (<a href="/recipes/tags/2d/">2d</a>, <a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/4d/">4d</a>, <a href="/recipes/tags/symion/">symion</a>). </p> <p>This is a modification of code posted at <a href="http://code.activestate.com/recipes/577715/" rel="nofollow">http://code.activestate.com/recipes/577715/</a> (r3)</p> <p>The original code produces a png image using the PIL module. It generates a Random 2D Slice of a 4D Mandelbrot Fractal.</p> <p>This extends the program into 3D with Visual Python 5.4, running under Python 2.7.1</p> <p>Changing vp_flag from 0 to 1 will restore program to original functionality. The program is interactive with keys q,w,e,r and x used to control visual points object.</p>