3D rotations and graphs
Author Message 3D rotations and graphs

Ivor,

You already know to go from 3D to 2D you just loose one axis
(say z)

X = x
Y = y

ignore z.

To Rotate:

SUB rotate (a, b, c, xrotate, yrotate, zrotate)

x0 = x
y0 = y
z0 = z

x1 = x0
y1 = y0 * COS(xrotate * rad) - z0 * SIN(xrotate * rad)
z1 = y0 * SIN(xrotate * rad) + z0 * COS(xrotate * rad)

x2 = z1 * SIN(yrotate * rad) + x1 * COS(yrotate * rad)
y2 = y1
z2 = z1 * COS(yrotate * rad) - x1 * SIN(yrotate * rad)

x3 = x2 * COS(zrotate * rad) - y2 * SIN(zrotate * rad)
y3 = x2 * SIN(zrotate * rad) + y2 * COS(zrotate * rad)
z3 = z2

x = x3
y = y3
z = z3

END SUB

Perspective is handled by dividing by the axis you dropped.

newX = f*x/z
newY = f*y/z

where f sets the amount of perspective.  You may have to
Translate your dataset away on this dropped axis so that you don't
flip points.

Jeff

Quote:
> Is it possible to write some code in Visual Basic to draw a scatterplot
> with 3 axis and then rotate it.  There are some fancy statistics
> packages that will do it but they don't do quite what I want.  Has
> anybody written some code already or do I have to start from scratch? I
> have tried hunting all over the web and in various newsgroups and come
> up with naught.

> Any tips appreciated

Tue, 28 Mar 2000 03:00:00 GMT  3D rotations and graphs

Oops

Quote:
> SUB rotate (a, b, c, xrotate, yrotate, zrotate)

should be

SUB rotate (x, y, z, xrotate, yrotate, zrotate)

Jeff

Tue, 28 Mar 2000 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages