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)

         rad = 3.14159 / 180

         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  
 
 [ 2 post ] 

 Relevant Pages 

1. 3D Camera rotation around any object in 3D space

2. 3d graph more precisely a 3D curve plotting

3. 3D Rotation Points

4. 3d rotation's

5. 3D rotation

6. 3D rotations...

7. 3D Rotation on z-axis...problem....

8. Problem with 3d camera view rotation...

9. Graphing 2d or 3d equasions.

10. Q about 3d graphing

11. PRB: Totals in % for 3D Pie Graphs

12. How to plot 3D graph ? - Help

 

 
Powered by phpBB® Forum Software