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
This commit is contained in:
Paul Davis 2011-02-24 18:55:33 +00:00
parent 0c5c1aafd0
commit 5ad82b1e6d
5 changed files with 29 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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*/

View file

@ -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);
}
}