summaryrefslogtreecommitdiff
path: root/src/ProjectionTangentialLSQ.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProjectionTangentialLSQ.cxx')
-rw-r--r--src/ProjectionTangentialLSQ.cxx92
1 files changed, 3 insertions, 89 deletions
diff --git a/src/ProjectionTangentialLSQ.cxx b/src/ProjectionTangentialLSQ.cxx
index 1a2f0f9..4235980 100644
--- a/src/ProjectionTangentialLSQ.cxx
+++ b/src/ProjectionTangentialLSQ.cxx
@@ -22,19 +22,12 @@ static double sec(double a) {
return 1.0 / cos(a);
}
-static double pi_d = asin(1.0) * 2.0, deg2rad = pi_d / 180.0;
-
#include "lsq_funcs.c"
-static double
-comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale,
- double tan_nick_m, double tan_dir_m,
- double x, double y, double pi_d);
-
int
ProjectionTangentialLSQ::comp_params(const Hills *h, ViewParams *parms) {
const Hill *tmp, *m1, *m2;
- double a_center_tmp, scale_tmp, a_nick_tmp;
+ double scale_tmp;
if (h->get_num() < 2) {
fprintf(stderr, "Please position at least 2 hills\n");
@@ -73,27 +66,6 @@ ProjectionTangentialLSQ::comp_params(const Hills *h, ViewParams *parms) {
}
}
-double
-ProjectionTangentialLSQ::angle_dist(double a1, double a2) {
- double ret;
-
- a1 = fmod(a1, 2.0 * pi_d);
- if (a1 < 0.0) {
- a1 = a1 + 2.0 * pi_d;
- }
- a2 = fmod(a2, 2.0 * pi_d);
- if (a2 < 0.0) {
- a2 = a2 + 2.0 * pi_d;
- }
-
- ret = fabs(a1 - a2);
- if (ret > pi_d) {
- ret = 2.0 * pi_d - ret;
- }
-
- return ret;
-}
-
struct data {
const Hills *h;
const ViewParams *old_params;
@@ -104,7 +76,7 @@ struct data {
static int
lsq_f (const gsl_vector * x, void *data, gsl_vector * f) {
struct data *dat = (struct data *) data;
- double c_view, c_nick, c_tilt, scale, k0, k1, u0, v0;
+ double c_view, c_nick, c_tilt, scale, k0, k1;
c_view = gsl_vector_get (x, 0);
c_nick = gsl_vector_get (x, 1);
@@ -135,7 +107,7 @@ lsq_f (const gsl_vector * x, void *data, gsl_vector * f) {
static int
lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) {
struct data *dat = (struct data *) data;
- double c_view, c_nick, c_tilt, scale, k0, k1, u0, v0;
+ double c_view, c_nick, c_tilt, scale, k0, k1;
c_view = gsl_vector_get (x, 0);
c_nick = gsl_vector_get (x, 1);
@@ -257,33 +229,6 @@ ProjectionTangentialLSQ::get_coordinates(double alph, double a_nick,
}
double
-ProjectionTangentialLSQ::comp_center_angle(double a1, double a2, double d1, double d2) {
- double sign1 = 1.0;
- double tan_acenter, tan_a1, tan_a2, a_center;
-
- tan_a1 = tan(a1);
- tan_a2 = tan(a2);
-
- tan_acenter = (((pow(((pow((1.0 + (tan_a1 * tan_a2)), 2.0) * ((d1 * d1) + (d2 * d2))) + (2.0 * d1 * d2 * ((2.0 * ((tan_a2 * tan_a1) - (tan_a2 * tan_a2))) - ((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) - 1.0))), (1.0 / 2.0)) * sign1) + ((1.0 - (tan_a1 * tan_a2)) * (d1 - d2))) / (2.0 * ((d2 * tan_a2) - (d1 * tan_a1))));
-
- a_center = atan(tan_acenter);
-
- if (a_center > 2.0 * pi_d) {
- a_center = a_center - 2.0 * pi_d;
- } else if (a_center < 0.0) {
- a_center = a_center + 2.0 * pi_d;
- }
-
- // atan(tan_dir_view) is not the only possible solution.
- // Choose the one which is close to m1->alph.
- if (fabs(a_center - a1) > pi_d/2.0) {
- a_center = a_center + pi_d;
- }
-
- return a_center;
-}
-
-double
ProjectionTangentialLSQ::comp_scale(double a1, double a2, double d1, double d2) {
double sign1 = 1.0;
double sc, tan_a1, tan_a2;
@@ -295,34 +240,3 @@ ProjectionTangentialLSQ::comp_scale(double a1, double a2, double d1, double d2)
return sc;
}
-
-static double
-comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale,
- double tan_nick_m, double tan_dir_m,
- double x, double y, double pi_d) {
- double y_tmp, x_tmp, sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res;
-
- y_tmp = - (((tan_nick_view - tan_nick_m) * n_scale) /
- (tan_nick_m * tan_nick_view + 1));
- x_tmp = - (((tan_dir_view - tan_dir_m) * n_scale) /
- (tan_dir_m * tan_dir_view + 1));
-
-
- sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) /
- (x*x + y*y);
-
- sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) /
- (x*x + y*y);
-
- sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2;
-
- res = asin(sin_a_tilt);
-
- if (res > pi_d / 4.0) {
- res = res - pi_d / 2.0;
- } else if (res < -pi_d / 4.0) {
- res = res + pi_d / 2.0;
- }
-
- return res;
-}