From 9f8d5ca7bd39b64974c0e6e15f1e3037f5cfad1f Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 24 Feb 2011 18:55:33 +0000 Subject: [PATCH] switch cartesian/spherical function names and make them use length. still a tweak needed here git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/3.0@8952 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/panner2d.cc | 19 ++++++++++--------- gtk2_ardour/speaker_dialog.cc | 5 +++-- libs/panners/vbap/vbap.cc | 3 +-- libs/pbd/cartesian.cc | 16 +++++++++++----- libs/pbd/pbd/cartesian.h | 8 ++++---- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/gtk2_ardour/panner2d.cc b/gtk2_ardour/panner2d.cc index ca7335520..51c42160c 100644 --- a/gtk2_ardour/panner2d.cc +++ b/gtk2_ardour/panner2d.cc @@ -496,15 +496,15 @@ Panner2d::on_expose_event (GdkEventExpose *event) cairo_fill (cr); cairo_restore (cr); - /* move the text in just a bit */ - - AngularVector textpos (target->position.azi, 0.75); - textpos.cartesian (c); - cart_to_gtk (c); - if (!small) { + cairo_set_font_size (cr, 16); + + /* move the text in just a bit */ + + AngularVector textpos (target->position.azi, target->position.ele, 0.85); + textpos.cartesian (c); + cart_to_gtk (c); cairo_move_to (cr, c.x, c.y); - cairo_set_font_size (cr, 10); cairo_show_text (cr, buf); } @@ -723,9 +723,10 @@ Panner2d::clamp_to_circle (double& x, double& y) { double azi, ele; double z = 0.0; + double l; - PBD::cart_to_azi_ele (x, y, z, azi, ele); - PBD::azi_ele_to_cart (azi, ele, x, y, z); + PBD::cartesian_to_spherical (x, y, z, azi, ele, l); + PBD::spherical_to_cartesian (azi, ele, 1.0, x, y, z); } void diff --git a/gtk2_ardour/speaker_dialog.cc b/gtk2_ardour/speaker_dialog.cc index 94e3dceea..c32211dd9 100644 --- a/gtk2_ardour/speaker_dialog.cc +++ b/gtk2_ardour/speaker_dialog.cc @@ -201,9 +201,10 @@ SpeakerDialog::clamp_to_circle (double& x, double& y) { double azi, ele; double z = 0.0; + double l; - PBD::cart_to_azi_ele (x, y, z, azi, ele); - PBD::azi_ele_to_cart (azi, ele, x, y, z); + PBD::cartesian_to_spherical (x, y, z, azi, ele, l); + PBD::spherical_to_cartesian (azi, ele, 1.0, x, y, z); } void diff --git a/libs/panners/vbap/vbap.cc b/libs/panners/vbap/vbap.cc index 124b30bc3..eff8a5ee4 100644 --- a/libs/panners/vbap/vbap.cc +++ b/libs/panners/vbap/vbap.cc @@ -122,7 +122,6 @@ VBAPanner::update () double degree_step_per_signal = (max_dir - min_dir) / (_signals.size() - 1); double signal_direction = min_dir; - int x = 1; for (vector::iterator s = _signals.begin(); s != _signals.end(); ++s) { @@ -153,7 +152,7 @@ VBAPanner::compute_gains (double gains[3], int speaker_ids[3], int azi, int ele) double small_g; double big_sm_g, gtmp[3]; - azi_ele_to_cart (azi,ele, cartdir[0], cartdir[1], cartdir[2]); + spherical_to_cartesian (azi, ele, 1.0, cartdir[0], cartdir[1], cartdir[2]); big_sm_g = -100000.0; gains[0] = gains[1] = gains[2] = 0; diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc index 196023f60..d15f9a3c2 100644 --- a/libs/pbd/cartesian.cc +++ b/libs/pbd/cartesian.cc @@ -24,19 +24,23 @@ using namespace std; void -PBD::azi_ele_to_cart (double azi, double ele, double& x, double& y, double& z) +PBD::spherical_to_cartesian (double azi, double ele, double len, double& x, double& y, double& z) { /* convert from cylindrical coordinates in degrees to cartesian */ static const double atorad = 2.0 * M_PI / 360.0 ; + + if (len == 0.0) { + len = 1.0; + } - x = cos (azi * atorad) * cos (ele * atorad); - y = sin (azi * atorad) * cos (ele * atorad); - z = sin (ele * atorad); + x = len * cos (azi * atorad) * cos (ele * atorad); + y = len * sin (azi * atorad) * cos (ele * atorad); + z = len * sin (ele * atorad); } void -PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& elevation) +PBD::cartesian_to_spherical (double x, double y, double z, double& azimuth, double& elevation, double& length) { #if 1 /* converts cartesian coordinates to cylindrical in degrees*/ @@ -62,6 +66,8 @@ PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& ele } else { elevation = 180.0 * (phi / M_PI); } + + length = rho; #else /* converts cartesian coordinates to cylindrical in degrees*/ diff --git a/libs/pbd/pbd/cartesian.h b/libs/pbd/pbd/cartesian.h index afa457946..ffc91c2fd 100644 --- a/libs/pbd/pbd/cartesian.h +++ b/libs/pbd/pbd/cartesian.h @@ -24,8 +24,8 @@ namespace PBD { -void azi_ele_to_cart (double azi, double ele, double& x, double& y, double& z); -void cart_to_azi_ele (double x, double y, double z, double& azi, double& ele); +void spherical_to_cartesian (double azi, double ele, double len, double& x, double& y, double& z); +void cartesian_to_spherical (double x, double y, double z, double& azi, double& ele, double& len); struct AngularVector; @@ -91,12 +91,12 @@ struct AngularVector { } void cartesian (CartesianVector& c) const { - azi_ele_to_cart (azi, ele, c.x, c.y, c.z); + spherical_to_cartesian (azi, ele, length, c.x, c.y, c.z); } }; inline void CartesianVector::angular (AngularVector& a) const { - cart_to_azi_ele (x, y, z, a.azi, a.ele); + cartesian_to_spherical (x, y, z, a.azi, a.ele, a.length); } } -- 2.11.4.GIT