Author Topic: Atan2  (Read 3153 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Atan2
« on: September 20, 2011, 12:18:18 PM »
Deleted
« Last Edit: May 05, 2015, 09:35:31 AM by Peter »

Charles Pegge

  • Guest
Re: Atan2
« Reply #1 on: September 20, 2011, 12:50:36 PM »
Hi Peter,

it is just called atan(y,x)

atn(y/x) is the usual Basic function

Charles

PS pi() asin() and acos() deg() and rad() are also available
« Last Edit: September 20, 2011, 12:58:03 PM by Charles Pegge »

Peter

  • Guest
Re: Atan2
« Reply #2 on: September 20, 2011, 01:31:04 PM »
Charles,

what about:   ArcTan
                   ArcSin
                   ArcCos ?

Charles Pegge

  • Guest
Re: Atan2
« Reply #3 on: September 20, 2011, 02:35:47 PM »
Peter,

Allow me to introduce deff

This lets you create your own float macros. It allows you to extend the core maths functions.

For instance:

deff arctan fpatan

deff arctn fld1 : fpatan


You can see such macros encoded in the Oxygen source code src/o2keyw.bas


data       "asin 17 fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fpatan"


Charles

Charles Pegge

  • Guest
Re: Atan2
« Reply #4 on: September 21, 2011, 04:03:21 AM »

Hi Peter,

deff was introduced about 1 year ago in Alpha 10. I have kept quiet about it :)

Back soon. Then I will look at your code.

Charles

Charles Pegge

  • Guest
Re: Atan2
« Reply #5 on: September 21, 2011, 06:29:05 AM »
Peter,

I try to hide them in the manual, but then I discover them a few months later. :)

Nice demo! the ball could almost pass for being intelligent.

There is a distance function available for 2D hypoteneuse.


dist = Sqr(dx*dx+dy*dy)

dist=hypot(dx,dy)

to make a customised 3D one using deff

deff hypot3
  fmul st0
  fxch st1
  fmul st0
  fxch st2
  fmul st0
  faddp st1
  faddp st1
  fsqrt
end deff

dist=hypot3(dx,dy,dz)



Charles
« Last Edit: September 21, 2011, 06:43:36 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Atan2
« Reply #6 on: September 21, 2011, 11:31:13 AM »
Thanks Peter

deff will take any assembler instructions and dot labels but not macros or variable names. All parameters are automatically pushed onto the fpu stack.

for more general purpose macros, there is the traditional C #define and of course def which works a bit like a DOS batch file macro with its %1..%9 argument substitutions.

There is also a cleaner   alternative to using multi-line #define(...)

macro(a,b,c)
...
end macro



Charles
« Last Edit: September 21, 2011, 11:35:32 AM by Charles Pegge »