views:

102

answers:

2

I'm trying to teach myself about 3D graphics, but I'm having trouble visualizing the 3D vectors involved.

Is there any good software that I can use to visualize 3D vectors?

For example, right now I'm learning about camera transformations, and it would be nice if I could easily plot the right/up/look/eye vectors.

I've tried Grapher.app and gnuplot, but it's very difficult to enter points into Grapher.app and gnuplot doesn't seem to be able to lock the aspect ratio.

+2  A: 

I don't know if this would be easier than Grapher.app or gnuplot, but you could write your own 3D graphics program that just plots the vectors.

Here's an example in OpenGL that draws the X, Y, and Z axis vectors.

Update: Here's a Java applet specifically focused on helping you visualize the vectors in camera transformations. Note the installation instructions: you have to install Java 3D.

Description: The Perspective Camera Parameters applet aims to familiarize students with the various parameter associated with a synthetic, perspective-projection camera. Users can adjust any of the following parameters: field-of-view width, field-of-view height, near clipping plane distance, far clipping plane distance, up vector, and look vector. The viewing frustum is visualized in a window, allowing students to understand how the parameters relate to the shape of the viewing frustum.

The same site has many components, such as axes, that you can use to set up a simple applet showing just the vectors you want.

LarsH
Hhmm… I hadn't considered that (I'm dealing with non-interactive 3D graphics), but that's not a bad idea. Thanks.
David Wolever
@Jay, who were you talking to?
LarsH
@David Wolever, if you create an app and open source it, I'm sure it would be helpful to others also.
Jay Askren
@LarsH: awesome, that looks really good. Thanks.
David Wolever
+3  A: 

Visual Python is a super easy library for 3D visualization.

For example, to show a sphere and arrow:

import time, math, visual

ball = visual.sphere(pos=(0,2,0), radius=1, color=visual.color.red)
vect = visual.arrow(pos=(2,0,0), axis=(2 ,2,-2))

visual.scene.forward = (.1, -.3, -1)  # controls the camera view angle

alt text

This window now also has all of the normal mouse interactivity, such as zooming and camera (i.e. viewing angle) rotation.

VPython is also easy to animate. For example, the following will rotate the arrow:

da = 2*math.pi/100
for timestep in range(100):
    angle = timestep*da
    vect.axis = (2+2*math.sin(angle), 2*math.cos(angle), -2)
    time.sleep(.1)
tom10
Awesome — that looks really good. Thanks a lot.
David Wolever
If I have more issues I'll open new questions for them… But just running exactly what you've got there, I don't get any sort of mouse interactivity. Is there some secret sauce I'm missing?
David Wolever
I'm using VPython from Ubuntu Linux, and there the middle mouse button zooms and the right mouse button rotates (and I didn't do anything special to get this). You say that you get none of this? You might want to try to set: visual.scene.autoscale=0, visual.scene.userzoom=1, and visual.scene.userspin=1 but I think the default is to allow interaction so this shouldn't be necessary.
tom10
Ah, I didn't try using other mouse buttons. On the Mac, using command, option and control seem to pan/zoom/scale (not necessarily in that order, though).
David Wolever