Atan2 function possible in ulisp?


Hi David

Do you think it would be possible to implement the true atan2 function in the floating point routines ?
I did some research and found that this function exist in the “math.h” library in arduino.
atan2 takes the atan of (y/x) where y and x are floats.
It would be a nice thing to have for my astronomy functions.
You dont have to implement it , but if you could tell me how to do it , I would appreciate it.

Kind regards ,
Ronny Suy


Hi Ronny,

I think the uLisp atan function already implements atan2, because it takes an optional second argument. Try it out, and let me know if it doesn’t do what you want.

Regards, David


Hi David

Yes , that’s correct , but the second parameter needs to be a integer in ulisp . It should be possible to be a float to be correct.
At least that’ s what I understood. See this article for example :

Regards ,


You’re correct; there is a bug in uLisp. The definition of fn_atan should be changed to:

object *fn_atan (object *args, object *env) {
  (void) env;
  object *arg = first(args);
  float div = 1.0;
  args = cdr(args);
  if (args != NULL) div = intfloat(first(args));
  return makefloat(atan2(intfloat(arg), div));

Thanks for finding that - it will be corrected in the next release.


Thanks David !

I’ve tested some values and it’s ok now.

Kind regards,