13
0

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
This commit is contained in:
Paul Davis 2011-02-24 04:27:48 +00:00
parent 0e9bc1d7b6
commit 7bfe5d6f4b

View File

@ -38,6 +38,31 @@ PBD::azi_ele_to_cart (double azi, double ele, double& x, double& y, double& z)
void void
PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& elevation) 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*/ /* converts cartesian coordinates to cylindrical in degrees*/
const double atorad = 2.0 * M_PI / 360.0; 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; elevation = atan_x_pl_y_per_z / atorad;
// distance = sqrtf (x*x + y*y + z*z); // distance = sqrtf (x*x + y*y + z*z);
#endif
} }