summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-02-24 18:55:33 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-02-24 18:55:33 +0000
commit5ad82b1e6d3a1b473137ab8b5f15ecf190eed51f (patch)
tree667407740e60ca0d5aed23660d726de56c868408
parent0c5c1aafd06f24442f31f87de1fd1f51d6ce9291 (diff)
switch cartesian/spherical function names and make them use length. still a tweak needed here
git-svn-id: svn://localhost/ardour2/branches/3.0@8952 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/panner2d.cc19
-rw-r--r--gtk2_ardour/speaker_dialog.cc5
-rw-r--r--libs/panners/vbap/vbap.cc3
-rw-r--r--libs/pbd/cartesian.cc16
-rw-r--r--libs/pbd/pbd/cartesian.h8
5 files changed, 29 insertions, 22 deletions
diff --git a/gtk2_ardour/panner2d.cc b/gtk2_ardour/panner2d.cc
index ca7335520f..51c42160ce 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 94e3dceead..c32211dd9f 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 124b30bc30..eff8a5ee43 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<Signal*>::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 196023f606..d15f9a3c27 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 afa4579465..ffc91c2fd6 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);
}
}