aboutsummaryrefslogtreecommitdiff
path: root/generic/Geo.c
diff options
context:
space:
mode:
authorlecoanet2005-10-19 10:58:11 +0000
committerlecoanet2005-10-19 10:58:11 +0000
commit418a729b9bdd7c899c444a889b0064fbc998f2a2 (patch)
tree2fc1fa329978350e24d73dff94c168d74d18b78f /generic/Geo.c
parente3dba13cb46272306b626406e2ca5493e6683dc0 (diff)
downloadtkzinc-418a729b9bdd7c899c444a889b0064fbc998f2a2.zip
tkzinc-418a729b9bdd7c899c444a889b0064fbc998f2a2.tar.gz
tkzinc-418a729b9bdd7c899c444a889b0064fbc998f2a2.tar.bz2
tkzinc-418a729b9bdd7c899c444a889b0064fbc998f2a2.tar.xz
Added the function ZnPointCartesianToPolar that is the reciprocal of
ZnPointPolarToCartesian.
Diffstat (limited to 'generic/Geo.c')
-rw-r--r--generic/Geo.c21
1 files changed, 21 insertions, 0 deletions
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