summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-05-28 19:22:39 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-05-28 19:22:39 +0200
commit83699b53de7288b1ffb5a4c901730bee32524f4d (patch)
treed6e929015630324b9e85d674af335c704d0cb1f2
parent47dbcc5c434c293da10039eb56a8393926b3137a (diff)
parent2dfdc09969b8c32887cb45b6f7ff286227ddfd27 (diff)
merge projection fixes
-rw-r--r--NEWS5
-rw-r--r--configure.ac2
-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
7 files changed, 36 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index f38cf52..f238bff 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
gipfel ChangeLog
=================
+gipfel-0.2.3
+ - Fix a major shortcoming in the rectilinear projection
+ code. This improves accuracy quite a bit, mostly in
+ wideangle images.
+
gipfel-0.2.2
- Fix a segfault if exif tool is not installed.
- Some optimizations.
diff --git a/configure.ac b/configure.ac
index 02c0479..b5b9208 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(gipfel, 0.2.2, Johannes.Hofmann@gmx.de)
+AC_INIT(gipfel, 0.2.3, Johannes.Hofmann@gmx.de)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/Panorama.H])
AC_CONFIG_HEADER(config.h)
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$