# Painless way to do 3D visualization

Sun Oct 8 18:59:31 CEST 2006

```Peter Beattie wrote:
> Hey folks,
>
> I need to do the following relatively simple 3D programming:
>
> I want to convert data from four-item tuples into 3D co-ordinates in a
> regular tetrahedron. Co-ordinates come in sequences of 10 to 20, and the
> individual dots in the tetrahedron need to be connected into
> discontinuous lines. A single tetrahedron should contain at least two,
> possibly more, such lines. I would like to show certain similarities in
> the sequences/lines, eg by changing color, thickness, or maybe attaching
> indeces to certain points in a particular sequence.
>
> I'd welcome suggestions as to what might be the most painless way to
> achieve this in Python. So far, I've only tinkered a little with
> VPython, but the lack of any decent documentation has proved to be a
> major turn-off.
>
> TIA!

What exactly are the four-items in the tuples?

I think this is what you need along with an example...

http://www.vpython.org/webdoc/visual/curve.html

from visual import *

# a simple polygon

points = [(0,0,0),(0,1,0),(1,1,0),(1,0,0),(0,0,0)]
curve(pos=points, color=color.red)

# a polygon as separate segments grouped together in a frame.

square2 = frame()
points = [(0,0,1),(0,1,1),(1,1,1),(1,0,1),(0,0,1)]
for i in xrange(len(points)-1):
curve(frame=square2, pos=[points[i],points[i+1]], color=color.blue)
square2.objects[2].color = color.green   # change a line segments color
square2.objects[2].radius = .02          # change a line segments thickness

# looking at objects after they are made.
print square2
print dir(square2)
print square2.objects
print dir(square2.objects[0])

```