World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 09-22-2007, 02:45 PM   #1
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
fabrizio.giudici is on a distinguished road
Default About the orbitView.setZoom()

Thanks to your suggestions of some weeks ago, now I'm able to control the view of my canvas. :-) Also with smooth animations. :-))

Now the question is: what are the proper values for the zoom parameter? I need to fit the view so a certain geographic sector is shown; I had initially wrote down some maths for computing the elevation of the camera, and that worked decently; but I see that the FlyToOrbitViewStateIterator only accepts a 'zoom' parameter. Now, after a few tries, it looks like my maths for the elevation works fine with the zoom too :-)) Is the zoom just an alias for the elevation?
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 09-22-2007, 05:08 PM   #2
dcollins
WWJ Dev. Team
 
Join Date: May 2007
Posts: 449
dcollins is on a distinguished road
Default

Hi Fabrizio,

When the view is looking straight down (pitch or tilt is zero), OrbitView's zoom will closely match its altitude. There is no guarantee however, that the two will be equivalent. Zoom is the distance between eye and the "look-at" point on the surface, whereas altitude is the eye height above sea level. If you only need an estimate of altitude, and your view will be looking straight down, then zoom can approximate the value you need.

FlyToOrbitViewStateIterator only operates on the independent attributes of OrbitView:
* look-at latitude & longitude
* heading
* pitch
* zoom
This is the set of attributes (as they are currently defined) that can be changed without affecting one another. Changing altitude, for example, will in most cases also affect look-at latitude & longitude, and zoom (and in some edge cases heading and pitch).

I encourage you to write your own OrbitViewStateIterator if you find that the default supplied with WorldWind doesn't suit your needs. There's no tutorial yet, but a short tour of the viewing code, especially BasicOrbitViewAnimator.java and FlyToOrbitViewStateIterator.java should get you on the right track.

Thanks,
Dave Collins
dcollins is offline   Reply With Quote
Old 09-22-2007, 05:17 PM   #3
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
fabrizio.giudici is on a distinguished road
Default

Thank you Dave.

Indeed zoom, according to the definition you gave, is just what I need, as I must control things in relationship with the "look-at" point.
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 09-22-2007, 08:49 PM   #4
nlneilson
Super Moderator
 
Join Date: Nov 2006
Location: Mojave & Oxnard California
Posts: 2,623
nlneilson is on a distinguished road
Default

dcollins: "altitude is the eye height above sea level" - - Good.

With pitch of zero the zoom would be the distance to the terrain or distance Above Ground Level, AGL. This is the convention used by pilots, etc.

WWJ often uses alt for AGL. If the terrain elevation is 5,000 ft (1524 meters) and the camera is 1,000 ft (305 m) above the terrain the alt should be 6,000 ft (1829 m) above sea level and not 1,000 ft (305 m). WW .net was the same way.
nlneilson is offline   Reply With Quote
Old 03-26-2009, 04:34 PM   #5
lembas
Member
 
Join Date: Oct 2007
Posts: 40
lembas is on a distinguished road
Default

What is the exact mathematical equation between:

* Altitude, which is view.getEyePosition().getElevation()
* Zoom, view.getZoom()
* Pitch angle, view.getPitch()
* Elevation, view.getCenterPosition().getElevation()

Some kind of Altitude = cosine(Pitch) * (Zoom + Elevation) ???
lembas is offline   Reply With Quote
Old 03-26-2009, 05:46 PM   #6
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
patmurris is an unknown quantity at this point
Default

The orbit view is defined as an eye always looking at a point (the center point) lying on the globe surface.

- Altitude is the eye altitude above sea level
- Zoom is the distance in meter between the eye and the center point on the surface.
- Pitch is the angle between the vertical (ellipsoid normal) at the center point and the eye forward vector
- Elevation is the center point elevation - the terrain elevation the eye is looking at.

Not sure this is answering your question though...
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 03-27-2009, 10:24 AM   #7
lembas
Member
 
Join Date: Oct 2007
Posts: 40
lembas is on a distinguished road
Default

Thank you Pat. I thought the same but something's wrong.

The equation should be:
Altitude = Zoom * cosine(Pitch) + Elevation

but I took a sample data
altitude = 6380.466112825255 m
zoom = 5789.086592250981 m
elevation = 3902.9342137254084 m
pitch = 64.68500279086172°
head = 0.0°
measured at
latitude= 39.68381186667483°
longitude= 44.30099387891051°

As you can see the result is not equal to the altitude
5789.086592250981 * cosine(64.68500279086172) + 3902.9342137254084 = 2289.99847 m

What could be the problem?
lembas is offline   Reply With Quote
Old 03-27-2009, 12:21 PM   #8
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
patmurris is an unknown quantity at this point
Default

Quote:
Originally Posted by lembas View Post
Thank you Pat. I thought the same but something's wrong. The equation should be:
Altitude = Zoom * cosine(Pitch) + Elevation
What could be the problem?
This is not the right formula - this one would measure the eye projected altitude at the vertical of the center point.
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 03-27-2009, 01:22 PM   #9
lembas
Member
 
Join Date: Oct 2007
Posts: 40
lembas is on a distinguished road
Default

So we do not know the equation.

My aim is to double-click to fly from one position to another. I want the beginning altitude and the final altitude be equal.

My code is:
Code:
wwd.getInputHandler().addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
      OrbitView view = (OrbitView)wwd.getView();
      final Position position =  view.computePositionFromScreenPoint(e.getX(), e.getY());
      Earth earth = ww3DAnimationView.getEarth();
      Angle head = view.getHeading();
      Angle pitch = view.getPitch();
      double elevation = position.getElevation();
      double altitude = 15000;//constant
      double calculatedZoomForConstantAltiude = (altitude - elevation) / Math.cos(pitch.getRadians());
      view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator(view, earth, position, head, pitch, calculatedZoomForConstantAltiude));
    }
    e.consume();
  }
});
Is there any other way?
lembas is offline   Reply With Quote
Old 03-27-2009, 02:29 PM   #10
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
patmurris is an unknown quantity at this point
Default

You have to make a drawing showing the globe, the view center point and the eye to properly understand the geometry involved. Make sure the pitch angle is in the right place - between the vertical at the center point and the eye forward vector. A common misunderstanding is to think of the pitch as the angle between the forward vector and the vertical under the eye.

If what you want to achieve is a constant eye altitude above sea level, you may just adjust the zoom using the difference between the current center point elevation and the target center point elevation multiplied by the pitch cosine. Something like:

cp1 is current view center point, cp2 is the target center point you clicked on.
target zoom = current zoom + (cp2 elev - cp1 elev) * cosine(pitch)

Note that in your code, view.computePositionFromScreenPoint will not account for terrain elevation - it intersects a line with the globe ellipsoid.
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:18 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.