aboutsummaryrefslogtreecommitdiff
path: root/generic/Geo.c
diff options
context:
space:
mode:
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