Maths Library, ATAN2

Greetings! First post here, so go easy on me! Not owned an Arduino long, and main field is not electronics, I'm more software orientated. I can do some coding, but I'm not exactly a great coder. With that in mind, here goes:

I've got an Adafruit IL9340 breakout board, which I've wired up to my UNO R3 and compiled & ran the library graphics test example. I've also written a really basic script that takes serial input from the PC and displays it on the little TFT screen.

This made me very happy indeed, so that's the level you're dealing with here.

My next idea is to write my own starfield screensaver recreation for it. Just for practise, so I can learn my way around it. I know exactly how I would do it in Lua, but I'm not so certain with the Arduino IDE. I'd generate a random angle and distance for a star to be born at, then convert that into a vector and the origin of the circle would be in the centre of the screen. Then calculate a speed of travel based on the vector, and an acceleration rate. Then I start drawing the star, adding the speed to the position and then increasing the speed with the acceleration rate, undrawing the old position as I go. When the star goes off the screen, kill it and create a new one.

In Lua I have these functions:

function angtovec(ang, dist);
 x=dist*math.cos(math.rad(angle))
 y=dist*math.sin(math.rad(angle))
 return(x,y);
end;

function vectoang(x1,y1,x2,y2);
 angle=math.deg(math.atan2(dy,dx));
 len= math.sqrt((dx*dx)+(dy*dy));
 return(angle, len);
end;

All the degree conversions are just because I prefer working in degrees rather than radians, but I'm flexible. What I need to do is create Arduino IDE versions of these (C++?). When I went to look at the maths library reference, I couldn't see ATAN2 (or 1!) but I did find them over in math.h - do they need setting up? Do I need to #include math.h to use them? Or can I simply call ang1=atan2(x,y)?

Many thanks in advance for your patience, and hopefully your help! And I hate to say it, but I'm bound to have more questions in the near future, especially about wiring and transistors...

do they need setting up?

No.

Do I need to #include math.h to use them?

The great thing about the Arduino is that in less time than it takes to ask that question, you could have gotten an answer from the Arduino IDE and Arduino.

Just call atan2, but note that the order of the arguments is as follows:

float radians = atan2(y, x);

PaulS: No.

Cheers, guessing I can just call it then :)

The great thing about the Arduino is that in less time than it takes to ask that question, you could have gotten an answer from the Arduino IDE and Arduino.

It probably would be without the two small children running around me, hah. Summer hols bring complications! Figured I'd take the chance during Peter Pan to sign up here ready for the questions I'll have and those I am already asking!

jremington: Just call atan2, but note that the order of the arguments is as follows:

float radians = atan2(y, x);

Awesome, thanks! I'd like to say "yeah I got them the wrong way round because I'm just giving an example", but it's an example of exactly the kind of mistake I am liable to make, so thanks again!