From 418a729b9bdd7c899c444a889b0064fbc998f2a2 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 19 Oct 2005 10:58:11 +0000 Subject: Added the function ZnPointCartesianToPolar that is the reciprocal of ZnPointPolarToCartesian. --- generic/Geo.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'generic/Geo.c') diff --git a/generic/Geo.c b/generic/Geo.c index 1fde494..cb070e5 100644 --- a/generic/Geo.c +++ b/generic/Geo.c @@ -1276,6 +1276,27 @@ ZnPointInAngle(int start_angle, } /* + * PointCartesianToPolar -- + * Convert a point in cartesian coordinates (delta_x, delta_y) + * in polar coordinates (rho, theta) + * in a reference system described by angle heading + * (angles running clockwise) to a point . + * + */ +void +ZnPointCartesianToPolar(ZnReal heading, + ZnReal *rho, + ZnReal *theta, /* in degree -180 , + 180 */ + ZnReal delta_x, + ZnReal delta_y) +{ + ZnReal theta_rad; + theta_rad = heading - ZnProjectionToAngle(delta_x,delta_y) - M_PI_2; + *theta = ZnRadDeg(theta_rad); + *rho = sqrt( delta_x * delta_x + delta_y * delta_y ); +} + +/* * PointPolarToCartesian -- * Convert a point in polar coordinates (rho, theta) * in a reference system described by angle heading -- cgit v1.1