[futurebasic] Re: futurebasic Digest 27 May 1998 21:00:56 -0000 Issue 397

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1998 : Group Archive : Group : All Groups

From: <CaverDave@...>
Date: Thu, 28 May 1998 01:51:31 EDT
>My trigs and maths aren't very good (neither is my spellin) so...
>
>If you have some points on a grid (X,Y) and you want to rotate them (sort
>of like a bit map rotate in a paint program but these are points),
>ah...er...ahem...cough... how do you do it?

   I worked on this for a long time, before I got it working both FAST and
CORRECTLY.  The following code is pasted straight out of one of my programs
(CavePlot).  The code below takes 3-D coordinants (3 arrays for X,Y, and Z)
and 2 rotation angles (Plan Rotation and Dip Rotation) to produce 2-D
coordinants in a separate set of arrays (Rotated-X and Rotated-Y).  The
initial X, Y, and Z coordinants are given in the arrays gX!(), gY!(), and
gZ!().  The new (rotated) coordinants are put into the arrays gRX!() and
gRY!().  The number of points in the arrays is given in the gC%.  The rotation
angles are gROT1! (top view rotation) and gROT2! (dip rotation).  gDEGRAD! is
a conversion factor from Degrees to Radians (probably 360/2*pi or something
like that?).

Here's the code...

 FSIN1!=SIN(gROT1!*gDEGRAD!)
 FCOS1!=COS(gROT1!*gDEGRAD!)
 FSIN2!=SIN(gROT2!*gDEGRAD!)
 FCOS2!=COS(gROT2!*gDEGRAD!)
 N%=gC%
 WHILE N%>0
    gRY!(N%)=gY!(N%)*FCOS1!-gX!(N%)*FSIN1!
    gRX!(N%)=gY!(N%)*FSIN1!+gX!(N%)*FCOS1!
    gRX!(N%)=gRX!(N%)*FCOS2!+gZ!(N%)*FSIN2!*gVEX!
    DEC(N%)
 WEND

   If you only want to rotate 2-D coordinants, just remove the lines dealing
with the gZ!() array and the gROT2! rotation angle.

David Herron
caverDave@...