summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.cxx1
-rw-r--r--src/Panorama.cxx8
-rw-r--r--src/ProjectionLSQ.H1
-rw-r--r--src/ProjectionLSQ.cxx10
-rw-r--r--src/lsq_rectilinear.mac21
5 files changed, 30 insertions, 11 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 63e89d2..881eb27 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -677,6 +677,7 @@ GipfelWidget::handle(int event) {
break;
case FL_DRAG:
set_mountain(Fl::event_x()-x(), Fl::event_y()-y());
+ comp_params();
return 1;
break;
case FL_RELEASE:
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index 06754ae..5f59103 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -413,8 +413,11 @@ Panorama::update_coordinates() {
double
Panorama::distance(double phi, double lam) {
- return acos(sin(view_phi) * sin(phi) +
- cos(view_phi) * cos(phi) * cos(view_lam - lam));
+ double d_lam = view_lam - lam;
+
+ return atan2(sqrt(pow(cos(phi) * sin(d_lam), 2.0) +
+ pow(cos(view_phi) * sin(phi) - sin(view_phi) * cos(phi) * cos(d_lam), 2.0)),
+ sin(view_phi) * sin(phi) + cos(view_phi) * cos(phi) * cos(d_lam));
}
double
@@ -438,7 +441,6 @@ Panorama::refraction(const Hill *m) {
return c * get_real_distance(m) / (2000.0 * (1.0 + a));
}
-
double
Panorama::nick(const Hill *m) {
double b, c, theta = refraction(m);
diff --git a/src/ProjectionLSQ.H b/src/ProjectionLSQ.H
index 44cc91d..d937114 100644
--- a/src/ProjectionLSQ.H
+++ b/src/ProjectionLSQ.H
@@ -17,6 +17,7 @@ class ProjectionLSQ {
int lsq(const Hills *m, ViewParams *parms, int distortion_correct);
protected:
+ static double pi;
double sec(double a);
public:
diff --git a/src/ProjectionLSQ.cxx b/src/ProjectionLSQ.cxx
index cdf9f04..461f36e 100644
--- a/src/ProjectionLSQ.cxx
+++ b/src/ProjectionLSQ.cxx
@@ -17,7 +17,7 @@
#include "ProjectionLSQ.H"
-static double pi_d = asin(1.0) * 2.0;
+double ProjectionLSQ::pi = asin(1.0) * 2.0;
ProjectionLSQ::ProjectionLSQ() {
}
@@ -238,10 +238,10 @@ ProjectionLSQ::get_coordinates(double alph, double a_nick,
const ViewParams *parms, double *x, double *y) {
// Normalize alph - parms->a_center to [-pi/2, pi/2]
- if (alph - parms->a_center > pi_d) {
- alph -= 2.0 * pi_d;
- } else if (alph - parms->a_center < -pi_d) {
- alph += 2.0 * pi_d;
+ if (alph - parms->a_center > pi) {
+ alph -= 2.0 * pi;
+ } else if (alph - parms->a_center < -pi) {
+ alph += 2.0 * pi;
}
*x = mac_x(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale,
diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac
index 5bd7ac9..377c24a 100644
--- a/src/lsq_rectilinear.mac
+++ b/src/lsq_rectilinear.mac
@@ -2,10 +2,25 @@
* rectilinear (pinhole) projection model with distortion correction
*/
-x : tan(m_view - c_view)$
-y : tan(c_nick - m_nick)$
-x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$
+/* switch to cartesian coordinates */
+c_x : cos(m_nick) * cos(m_view - c_view)$
+c_y : cos(m_nick) * sin(m_view - c_view)$
+c_z : sin(m_nick)$
+
+/* nick rotation */
+c_x_rot : cos(c_nick) * c_x + sin(c_nick) * c_z$
+c_y_rot : c_y$
+c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$
+
+/* pinhole projection */
+x : c_y_rot / c_x_rot$
+y : -c_z_rot / c_x_rot$
+
+/* rotation around view axis */
+x_rot : y * sin(c_tilt) + x * cos(c_tilt) + x0$
y_rot : y * cos(c_tilt) - x * sin(c_tilt)$
+
+/* distortion correction */
d : x_rot ^ 2 + y_rot ^ 2$
dist_fact : d ^ 2 * k1 + d * k0$
x_dist : x_rot * (1 + dist_fact) * scale$