home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 4
/
CDPD_IV.bin
/
e
/
mailinglists
/
amigae.0993sept.archive
/
000074_George_Beasley:.msg
< prev
next >
Wrap
Text File
|
1994-05-26
|
2KB
|
61 lines
----------------------------------------------------------------------------
PROBEMS WITH THE TRIG FUNCTIONS IN MATHTRANS.LIBRARY
I have a problem. I need, given an angle and the distance to move at that
angle, to know the delta_x and delta_y so that I can move an object to the
new location. To do this I am using the MathFFP and MathTrans libraries.
If my old math notes are correct, the way to do this is with the following
two equations:
delta_x = cos( angle in radians ) * radius
delta_y = sin( angle in radians ) * radius
My first problem is that my angle is in degrees, so I need to convert it to
radians. To do this (again with the help of my old math notes), I believe
the eauation is:
pi
radians = ------ * degrees
180
Converting this all to E, I get:
PROC newXY( degrees, radius )
DEF delta_x,
delta_y
delta_x = SpFix( SpMul( SpCos( SpMul( SpDiv( 3.14159265, 180.0 ),
SpFlt( degrees ))), SpFlt( radius )))
delta_y = SpFix( SpMul( SpSin( SpMul( SpDiv( 3.14159265, 180.0 ),
SpFlt( degrees ))), SpFlt( radius )))
pos_x:= pos_x + delta_x
pos_y:= pos_y + delta_y
ENDPROC
Now for the problem, this does not work. The numbers that I get do not come
out right (not even close). What am I doing wrong. Can anyone help me or
possible give me a routine that will do the same thing?
NOTE: I am loading the library correclty and pos_x and pos_y are defined
as globals in the beginning of the program.
Thank you in advance.
George Beasley...
----------------------------------------------------------------------------
MODULE 'WiZkId'
PROC main()
wizkid.inetaddress:='Politikill@cup.portal.com'
wizkid.realname:='Jeffrey J Peden ]['
ENDPROC
*-- GammaTag Version 2.8 --*
*-- What this country needs is a good five-cent nickel.