[GRASS-user] atan() in r.mapcalc

Glynn Clements glynn at gclements.plus.com
Wed Jul 4 11:30:58 EDT 2007


"Carlos \"Guâno\" Grohmann" wrote:

> from the man page:
> atan(x,y)               inverse tangent of y/x (result is in degrees)
> 
> is this correct? is it y/x or x/y?

The documentation is correct. When r.mapcalc's atan() function is
passed two arguments, it calls the ANSI C atan2() function with the
arguments swapped, then converts the result from -PI..PI radians to
0..360 degrees:

	res[i] = RADIANS_TO_DEGREES * atan2(arg2[i], arg1[i]);
	if (res[i] < 0)
		res[i] += 360.0;

The different argument order may be confusing, but changing it would
break existing scripts.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list