atan2

I need to convert Cartesian to spherical coordinates at run-time (long story) and the standard way uses the atan2 function. Does Glulx have such a thing built in? Since this calculation might happen multiple times a turn I’m a bit worried about speed.

Yes, there’s a phrase “To decide which real number is the tangent of (R - a real number)…”

Edit, oh, right atan2. Sorry! There’s an @atan2 opcode, so something like

[ Atan2 y x res;
@atan2 y x res;
return res;
];

Wonderful, thanks!

(Nominated for Most Newbie-Frightening Inform 7 Post Ever) :slight_smile:

Oh, it’s OK, for most things you can use the built-in trig functions.

eblong.com/zarf/glulx/glulx-spec_2.html now makes that much more sense, and it’s cool to have a practical example. So, thanks.