Hi..

I am trying to write a 3D graphics routine will transform a length and two
angles into x,y,z coordinates.

L = distance of point from a constant centre of rotation (say xr,yr,zr)
A1 = Rotation in x-y plane
A2 = Rotation in x-z plane

Using these I believe I can represent the location of any point in 3D space?
Am I right...?

For displaying on the screen I need to convert these to x,y,z coords.  I have
been fiddling for a while with the following -

x = xr + L*SIN(A1)*COS(A2)
y = yr + L*COS(A1)
z = zr + L*SIN(A2)

When complete, I hope to be able to pass this routine a couple of angles, and
it will draw a shape rotated by those angles, as shown here -

x = xr + L*SIN(A1 + XYOFFSET)*COS(A2 + XZOFFSET)
y = yr + L*COS(A1 + XYOFFSET)
z = zr + L*SIN(A2 + XZOFFSET)

where XYOFFSET and XZOFFSET are the rotation of the whole shape in the x-y and
x-z planes respectively.

This, however, refuses to work... and I believe it.  My maths stopped after
A levels.

PPPLLLLLEEEEAAAASSSSE can someone help me... before I go completely mad!!!

(can't think of a .sig at the mo)

writes:

Quote:> Hi..

>    I am trying to write a 3D graphics routine will transform a length and
two
> angles into x,y,z coordinates.

>    L = distance of point from a constant centre of rotation (say xr,yr,zr)
>   A1 = Rotation in x-y plane
>   A2 = Rotation in x-z plane

> Using these I believe I can represent the location of any point in 3D
space?
> Am I right...?

> For displaying on the screen I need to convert these to x,y,z coords.  I
have
> been fiddling for a while with the following -

>   x = xr + L*SIN(A1)*COS(A2)
>   y = yr + L*COS(A1)
>   z = zr + L*SIN(A2)

At first I thought you were using a spherical coordinate system, but then I
realized that it is a little different.  Anyway, I worked out the equations,
and here they are ...

x = xr + L*COS(A1)*COS(A2)
y = yr + L*COS(A2)*SIN(A1)
z = zr + L*COS(A1)*SIN(A2)

These should work for you.  If you have any problems, feel free to e-mail!

-- Dan
*****************************************************************************
dshipley at cs.umr.edu
or r092592  at apollo.civil.umr.edu     (The University of Missouri - Rolla)
or dan      at ee.umr.edu                    UMR ... The BLACK HOLE !!!
*****************************************************************************
!

Hello!

I am looking for a set of routines to show 3D objects
on an X display, e.g.

I'm not too much concerned with the quality of the image. I just
want to recognize a ball as a ball and a cylinder as a cylinder.

Hope somebody can help,

- Joerg

*********************************************************************

MPI fuer molekulare Physiologie
Rheinlanddamm 201
44139 Dortmund
Germany                               +49 (0)231 1206 384
*********************************************************************