summaryrefslogtreecommitdiff
path: root/libs/pbd/cartesian.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-02-24 04:27:48 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-02-24 04:27:48 +0000
commit7bfe5d6f4bc95e5141b20952d0c0d439fdffc947 (patch)
tree516b67ffb0b50bc90cd2b9240471ad6f4684a91d /libs/pbd/cartesian.cc
parent0e9bc1d7b6519918b5257b4dc39430e2cdca3df1 (diff)
new implementation of cartesian -> elevation, avoiding baroque code inherited from VBAP distribution
git-svn-id: svn://localhost/ardour2/branches/3.0@8947 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/cartesian.cc')
-rw-r--r--libs/pbd/cartesian.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc
index c09e00b189..196023f606 100644
--- a/libs/pbd/cartesian.cc
+++ b/libs/pbd/cartesian.cc
@@ -38,6 +38,31 @@ PBD::azi_ele_to_cart (double azi, double ele, double& x, double& y, double& z)
void
PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& elevation)
{
+#if 1
+ /* converts cartesian coordinates to cylindrical in degrees*/
+
+ double rho, theta, phi;
+
+ rho = sqrt (x*x + y*y + z*z);
+ phi = acos (1.0/rho);
+ theta = atan2 (y, x);
+
+ /* XXX for now, clamp phi to zero */
+
+ phi = 0.0;
+
+ if (theta < 0.0) {
+ azimuth = 180.0 - (180.0 * (theta / M_PI)); /* LHS is negative */
+ } else {
+ azimuth = 180.0 * (theta / M_PI);
+ }
+
+ if (phi < 0.0) {
+ elevation = 180.0 - (180.0 * (phi / M_PI)); /* LHS is negative */
+ } else {
+ elevation = 180.0 * (phi / M_PI);
+ }
+#else
/* converts cartesian coordinates to cylindrical in degrees*/
const double atorad = 2.0 * M_PI / 360.0;
@@ -77,5 +102,6 @@ PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& ele
elevation = atan_x_pl_y_per_z / atorad;
// distance = sqrtf (x*x + y*y + z*z);
+#endif
}