[grits] Increase camera angle to 60 degrees
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grits] Increase camera angle to 60 degrees
- Date: Thu, 16 Feb 2012 23:18:14 +0000 (UTC)
commit 7138d9be203921e2eaa3168932c463ed790456c0
Author: Andy Spencer <andy753421 gmail com>
Date: Fri Feb 10 18:26:50 2012 +0000
Increase camera angle to 60 degrees
Using the 30 degree viewing angle looks reasonable realistic,
but is difficult to use since it requires much more panning.
Derivation of FOV_DIST for a 1600x1200 monitor
with a vertical viewing angle of 60 degrees:
--- +.
| | '-. angle
height | | '-./
(px) | | /'-.
| +------|---+ (o) eye
| | \ .-'
| | .-'
| | .-'
--- +-'
|----------|
FOV_DIST (px)
height = 1200 px
angle = 60 deg
fov_dist = cot(angle/2)*(height/2) = ~1039.23
Derivation of angle for window of a given height:
angle = atan((height/2)/FOV_DIST)*2
src/grits-opengl.c | 2 +-
src/grits-util.h | 2 +-
src/grits-viewer.c | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/grits-opengl.c b/src/grits-opengl.c
index 5bf1710..1b2cce9 100644
--- a/src/grits-opengl.c
+++ b/src/grits-opengl.c
@@ -67,7 +67,7 @@ static void _set_visuals(GritsOpenGL *opengl)
double width = GTK_WIDGET(opengl)->allocation.width;
double height = GTK_WIDGET(opengl)->allocation.height;
- double ang = atan(height/FOV_DIST);
+ double ang = atan((height/2)/FOV_DIST)*2;
double atmos = 100000;
double near = MAX(elev*0.75 - atmos, 50); // View 100km of atmosphere
double far = elev + 2*EARTH_R + atmos; // on both sides of the earth
diff --git a/src/grits-util.h b/src/grits-util.h
index 8e7a2fd..9a22ab5 100644
--- a/src/grits-util.h
+++ b/src/grits-util.h
@@ -180,7 +180,7 @@ void grits_bounds_set_bounds(GritsBounds *bounds,
*
* Used by GritsOpenGL to set up the drawing window
*/
-#define FOV_DIST 2078.46
+#define FOV_DIST (1039.23)
/**
* MPPX:
diff --git a/src/grits-viewer.c b/src/grits-viewer.c
index b4b672a..f7d70e9 100644
--- a/src/grits-viewer.c
+++ b/src/grits-viewer.c
@@ -163,11 +163,11 @@ static gboolean on_motion_notify(GritsViewer *viewer, GdkEventMotion *event, gpo
gdouble lat, lon, elev, scale, rx, ry, rz;
grits_viewer_get_location(GRITS_VIEWER(viewer), &lat, &lon, &elev);
grits_viewer_get_rotation(GRITS_VIEWER(viewer), &rx, &ry, &rz);
- scale = (elev/EARTH_R/40) * (sin(deg2rad(ABS(rx)))*4+1);
+ scale = (elev/EARTH_R/14.1) * (sin(deg2rad(ABS(rx)))*4+1);
switch (viewer->drag_mode) {
- case GRITS_DRAG_PAN: grits_viewer_pan(viewer, -y*scale, x*scale, 0); break;
+ case GRITS_DRAG_PAN: grits_viewer_pan(viewer, -y*scale*0.782, x*scale, 0); break;
case GRITS_DRAG_ZOOM: grits_viewer_zoom(viewer, pow(2, -y/500)); break;
- case GRITS_DRAG_TILT: grits_viewer_rotate(viewer, y/30, 0, x/20); break;
+ case GRITS_DRAG_TILT: grits_viewer_rotate(viewer, y/10, 0, x/10); break;
}
viewer->drag_x = event->x;
viewer->drag_y = event->y;
@@ -587,7 +587,7 @@ static void grits_viewer_init(GritsViewer *viewer)
viewer->time = time(NULL);
viewer->location[0] = 40;
viewer->location[1] = -100;
- viewer->location[2] = 4*EARTH_R;
+ viewer->location[2] = EARTH_R;
viewer->rotation[0] = 0;
viewer->rotation[1] = 0;
viewer->rotation[2] = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]